|
@@ -11,6 +11,7 @@ import (
|
|
|
"ERP_storage/models/Contract"
|
|
"ERP_storage/models/Contract"
|
|
|
"ERP_storage/models/Property"
|
|
"ERP_storage/models/Property"
|
|
|
"ERP_storage/models/Stock"
|
|
"ERP_storage/models/Stock"
|
|
|
|
|
+ "errors"
|
|
|
"fmt"
|
|
"fmt"
|
|
|
"github.com/beego/beego/v2/adapter/orm"
|
|
"github.com/beego/beego/v2/adapter/orm"
|
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
beego "github.com/beego/beego/v2/server/web"
|
|
@@ -797,6 +798,9 @@ func (c *StockController) StockIn_Add() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
func StockIn_Edit_StockMonth(T_date string, T_depot_id int, allProductList []int) error {
|
|
func StockIn_Edit_StockMonth(T_date string, T_depot_id int, allProductList []int) error {
|
|
|
|
|
+ if len(T_date) == 0 {
|
|
|
|
|
+ return errors.New("日期不能为空")
|
|
|
|
|
+ }
|
|
|
date, _ := lib.DateStrToTime(T_date)
|
|
date, _ := lib.DateStrToTime(T_date)
|
|
|
|
|
|
|
|
//if date.Year() == time.Now().Year() && date.Month() == time.Now().Month() {
|
|
//if date.Year() == time.Now().Year() && date.Month() == time.Now().Month() {
|
|
@@ -891,13 +895,14 @@ func (c *StockController) StockIn_Edit() {
|
|
|
|
|
|
|
|
// 查询入库信息
|
|
// 查询入库信息
|
|
|
stockIn, err := StockInDao.Read_StockIn_ByT_number(T_number)
|
|
stockIn, err := StockInDao.Read_StockIn_ByT_number(T_number)
|
|
|
- T_old_date := stockIn.T_date
|
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+ T_old_date := stockIn.T_date
|
|
|
|
|
+
|
|
|
// 查询入库产品信息
|
|
// 查询入库产品信息
|
|
|
productOldList := StockInProductDao.Read_StockInProduct_List_ByT_number(stockIn.T_number)
|
|
productOldList := StockInProductDao.Read_StockInProduct_List_ByT_number(stockIn.T_number)
|
|
|
|
|
|
|
@@ -1541,9 +1546,6 @@ func (c *StockController) StockIn_Excel_Batch() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
productList := StockInProductDao.Read_StockInProduct_List_ByT_number(stockIn.T_number)
|
|
productList := StockInProductDao.Read_StockInProduct_List_ByT_number(stockIn.T_number)
|
|
|
- productList = append(productList, productList...)
|
|
|
|
|
- productList = append(productList, productList...)
|
|
|
|
|
- productList = append(productList, productList...)
|
|
|
|
|
var pList []Stock.StockInProduct_R
|
|
var pList []Stock.StockInProduct_R
|
|
|
for _, v := range productList {
|
|
for _, v := range productList {
|
|
|
pList = append(pList, Stock.StockInProductToStockInProduct_R(v))
|
|
pList = append(pList, Stock.StockInProductToStockInProduct_R(v))
|
|
@@ -2568,7 +2570,7 @@ func (c *StockController) StockOut_Edit() {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 删除入库
|
|
|
|
|
|
|
+// 删除出库
|
|
|
func (c *StockController) StockOut_Del() {
|
|
func (c *StockController) StockOut_Del() {
|
|
|
|
|
|
|
|
T_number := c.GetString("T_number") // 入库单号
|
|
T_number := c.GetString("T_number") // 入库单号
|
|
@@ -2580,7 +2582,7 @@ func (c *StockController) StockOut_Del() {
|
|
|
StockDao := Stock.NewStock(o)
|
|
StockDao := Stock.NewStock(o)
|
|
|
DeviceDao := Stock.NewDevice(o)
|
|
DeviceDao := Stock.NewDevice(o)
|
|
|
|
|
|
|
|
- // 查询入库信息
|
|
|
|
|
|
|
+ // 查询出库信息
|
|
|
stockOut, err := StockOutDao.Read_StockOut_ByT_number(T_number)
|
|
stockOut, err := StockOutDao.Read_StockOut_ByT_number(T_number)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
o.Rollback()
|
|
@@ -2885,10 +2887,6 @@ func (c *StockController) StockOut_Excel_Batch() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
productList := StockOutProductDao.Read_StockOutProduct_List(stockOut.T_number)
|
|
productList := StockOutProductDao.Read_StockOutProduct_List(stockOut.T_number)
|
|
|
- productList = append(productList, productList...)
|
|
|
|
|
- productList = append(productList, productList...)
|
|
|
|
|
- productList = append(productList, productList...)
|
|
|
|
|
- productList = append(productList, productList...)
|
|
|
|
|
|
|
|
|
|
var pList []Stock.StockOutProduct_R
|
|
var pList []Stock.StockOutProduct_R
|
|
|
for _, v := range productList {
|
|
for _, v := range productList {
|
|
@@ -3171,6 +3169,44 @@ func generateMonthList(startMonth time.Time, t_type string) []string {
|
|
|
return months
|
|
return months
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 我的申请列表
|
|
|
|
|
+func (c *StockController) StockOut_Apply_List() {
|
|
|
|
|
+ // 分页参数 初始化
|
|
|
|
|
+ page, _ := c.GetInt("page")
|
|
|
|
|
+ if page < 1 {
|
|
|
|
|
+ page = 1
|
|
|
|
|
+ }
|
|
|
|
|
+ page_z, _ := c.GetInt("page_z")
|
|
|
|
|
+ if page_z < 1 {
|
|
|
|
|
+ page_z = conf.Page_size
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 查询
|
|
|
|
|
+ T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
|
|
+ T_state, _ := c.GetInt("T_state")
|
|
|
|
|
+ T_contract_number := c.GetString("T_contract_number")
|
|
|
|
|
+ T_start_date := c.GetString("T_start_date")
|
|
|
|
|
+ T_end_date := c.GetString("T_end_date")
|
|
|
|
|
+ T_name := c.GetString("T_name")
|
|
|
|
|
+
|
|
|
|
|
+ userList, _ := NatsServer.Read_User_List_All()
|
|
|
|
|
+ Account.Read_User_All_Map(userList)
|
|
|
|
|
+ Basic.Read_Depot_All_Map()
|
|
|
|
|
+
|
|
|
|
|
+ StockOutDao := Stock.NewStockOut(orm.NewOrm())
|
|
|
|
|
+ R_List, R_cnt := StockOutDao.Read_StockOut_Audit_List(c.User.T_uuid, T_name, Stock.StockOutTypeApply, T_state, T_depot_id, T_contract_number, T_start_date, T_end_date, page, page_z)
|
|
|
|
|
+
|
|
|
|
|
+ var r_jsons lib.R_JSONS
|
|
|
|
|
+ r_jsons.Num = R_cnt
|
|
|
|
|
+ r_jsons.Data = R_List
|
|
|
|
|
+ r_jsons.Page = page
|
|
|
|
|
+ r_jsons.Page_size = int(math.Ceil(float64(R_cnt) / float64(page_z)))
|
|
|
|
|
+
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: r_jsons}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 出库申请
|
|
// 出库申请
|
|
|
func (c *StockController) StockOut_Apply() {
|
|
func (c *StockController) StockOut_Apply() {
|
|
|
|
|
|
|
@@ -3192,7 +3228,6 @@ func (c *StockController) StockOut_Apply() {
|
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
T_product := c.GetString("T_product")
|
|
T_product := c.GetString("T_product")
|
|
|
T_remark := c.GetString("T_remark")
|
|
T_remark := c.GetString("T_remark")
|
|
|
- //T_date := c.GetString("T_date")
|
|
|
|
|
T_project := c.GetString("T_project")
|
|
T_project := c.GetString("T_project")
|
|
|
T_company_name := c.GetString("T_company_name")
|
|
T_company_name := c.GetString("T_company_name")
|
|
|
T_payment_method := c.GetString("T_payment_method")
|
|
T_payment_method := c.GetString("T_payment_method")
|
|
@@ -3208,18 +3243,18 @@ func (c *StockController) StockOut_Apply() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
var_ := Stock.StockOut{
|
|
var_ := Stock.StockOut{
|
|
|
- T_number: T_number,
|
|
|
|
|
- T_contract_number: T_contract_number,
|
|
|
|
|
- T_depot_id: T_depot_id,
|
|
|
|
|
- T_type: 1,
|
|
|
|
|
- //T_date: T_date,
|
|
|
|
|
- T_receive: c.User.T_uuid,
|
|
|
|
|
- T_remark: T_remark,
|
|
|
|
|
- T_project: T_project,
|
|
|
|
|
- T_submit: c.User.T_uuid,
|
|
|
|
|
- T_state: Stock.StockOutWaitAudit,
|
|
|
|
|
- T_company_name: T_company_name,
|
|
|
|
|
- T_payment_method: T_payment_method,
|
|
|
|
|
|
|
+ T_number: T_number,
|
|
|
|
|
+ T_contract_number: T_contract_number,
|
|
|
|
|
+ T_depot_id: T_depot_id,
|
|
|
|
|
+ T_type: 1,
|
|
|
|
|
+ T_application_date: time.Now().Format("2006-01-02"),
|
|
|
|
|
+ T_receive: c.User.T_uuid,
|
|
|
|
|
+ T_remark: T_remark,
|
|
|
|
|
+ T_project: T_project,
|
|
|
|
|
+ T_submit: c.User.T_uuid,
|
|
|
|
|
+ T_state: Stock.StockOutWaitAudit,
|
|
|
|
|
+ T_company_name: T_company_name,
|
|
|
|
|
+ T_payment_method: T_payment_method,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
o.Begin()
|
|
o.Begin()
|
|
@@ -3251,6 +3286,12 @@ func (c *StockController) StockOut_Apply() {
|
|
|
product, _ := Basic.Read_Product_ById(product_id)
|
|
product, _ := Basic.Read_Product_ById(product_id)
|
|
|
|
|
|
|
|
num, _ := strconv.Atoi(strings.Split(v, "-")[1])
|
|
num, _ := strconv.Atoi(strings.Split(v, "-")[1])
|
|
|
|
|
+ if num == 0 {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("%s出库数量不能为0!", product.T_name)}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
// 2、添加出库产品清单
|
|
// 2、添加出库产品清单
|
|
|
stockOutProduct := Stock.StockOutProduct{
|
|
stockOutProduct := Stock.StockOutProduct{
|
|
|
T_number: T_number,
|
|
T_number: T_number,
|
|
@@ -3291,17 +3332,11 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
|
|
|
|
|
T_number := c.GetString("T_number") // 出库单号
|
|
T_number := c.GetString("T_number") // 出库单号
|
|
|
//T_depot_id, _ := c.GetInt("T_depot_id")
|
|
//T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
- T_date := c.GetString("T_date")
|
|
|
|
|
- T_receive := c.GetString("T_receive")
|
|
|
|
|
T_project := c.GetString("T_project")
|
|
T_project := c.GetString("T_project")
|
|
|
T_product := c.GetString("T_product")
|
|
T_product := c.GetString("T_product")
|
|
|
T_remark := c.GetString("T_remark")
|
|
T_remark := c.GetString("T_remark")
|
|
|
- _, is := lib.DateStrToTime(T_date)
|
|
|
|
|
- if !is {
|
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 202, Msg: "日期格式错误!"}
|
|
|
|
|
- c.ServeJSON()
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ T_company_name := c.GetString("T_company_name")
|
|
|
|
|
+ T_payment_method := c.GetString("T_payment_method")
|
|
|
|
|
|
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "仓库管理", "修改出库", T_product)
|
|
NatsServer.AddUserLogs(c.User.T_uuid, "仓库管理", "修改出库", T_product)
|
|
|
o := orm.NewOrm()
|
|
o := orm.NewOrm()
|
|
@@ -3318,7 +3353,6 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- T_old_date := StockOut.T_date
|
|
|
|
|
// 查询入库产品信息
|
|
// 查询入库产品信息
|
|
|
productOldList := StockOutProductDao.Read_StockOutProduct_List(StockOut.T_number)
|
|
productOldList := StockOutProductDao.Read_StockOutProduct_List(StockOut.T_number)
|
|
|
|
|
|
|
@@ -3338,13 +3372,31 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
if _, ok := allProductListMap[product.T_product_id]; !ok {
|
|
if _, ok := allProductListMap[product.T_product_id]; !ok {
|
|
|
allProductListMap[product.T_product_id] = struct{}{}
|
|
allProductListMap[product.T_product_id] = struct{}{}
|
|
|
}
|
|
}
|
|
|
|
|
+ if StockOut.T_state != Stock.StockOutAuditManagerUnPass && StockOut.T_state != Stock.StockOutAuditFinanceUnPass {
|
|
|
|
|
+ // 减少占用库存
|
|
|
|
|
+ product2, _ := Basic.Read_Product_ById(product.T_product_id)
|
|
|
|
|
+ _, err = StockDao.AddOrUpdate_Occupy_Stock(StockOut.T_depot_id, product2.Id, product2.T_class, product2.T_name, product2.T_model, product.T_num, 1)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "更新占用库存失败"}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
productNewList := lib.SplitString(T_product, "|")
|
|
productNewList := lib.SplitString(T_product, "|")
|
|
|
productNewMap := map[int]dto.StockProduct{}
|
|
productNewMap := map[int]dto.StockProduct{}
|
|
|
for _, v := range productNewList {
|
|
for _, v := range productNewList {
|
|
|
product_id, _ := strconv.Atoi(strings.Split(v, "-")[0])
|
|
product_id, _ := strconv.Atoi(strings.Split(v, "-")[0])
|
|
|
|
|
+ product, _ := Basic.Read_Product_ById(product_id)
|
|
|
num, _ := strconv.Atoi(strings.Split(v, "-")[1])
|
|
num, _ := strconv.Atoi(strings.Split(v, "-")[1])
|
|
|
|
|
+ if num == 0 {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("%s出库数量不能为0!", product.T_name)}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
T_relation_sn := strings.Split(v, "-")[2]
|
|
T_relation_sn := strings.Split(v, "-")[2]
|
|
|
stockProduct := dto.StockProduct{
|
|
stockProduct := dto.StockProduct{
|
|
|
T_product_id: product_id,
|
|
T_product_id: product_id,
|
|
@@ -3356,6 +3408,15 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
if _, ok := allProductListMap[product_id]; !ok {
|
|
if _, ok := allProductListMap[product_id]; !ok {
|
|
|
allProductListMap[product_id] = struct{}{}
|
|
allProductListMap[product_id] = struct{}{}
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ // 增加占用库存
|
|
|
|
|
+ _, err = StockDao.AddOrUpdate_Occupy_Stock(StockOut.T_depot_id, product.Id, product.T_class, product.T_name, product.T_model, num, 2)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "更新占用库存失败"}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 判断产品列表信息是否相同
|
|
// 判断产品列表信息是否相同
|
|
@@ -3365,7 +3426,6 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
if len(needDelete) > 0 {
|
|
if len(needDelete) > 0 {
|
|
|
// 删除入库产品列表
|
|
// 删除入库产品列表
|
|
|
for _, v := range needDelete {
|
|
for _, v := range needDelete {
|
|
|
- product, _ := Basic.Read_Product_ById(v.T_product_id)
|
|
|
|
|
// 删除入库产品列表
|
|
// 删除入库产品列表
|
|
|
err = StockOutProductDao.Delete_StockOutProduct(StockOut.T_number, StockOut.T_depot_id, v.T_product_id)
|
|
err = StockOutProductDao.Delete_StockOutProduct(StockOut.T_number, StockOut.T_depot_id, v.T_product_id)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -3374,23 +3434,12 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 增加库存
|
|
|
|
|
- _, err = StockDao.AddOrUpdate_Occupy_Stock(StockOut.T_depot_id, product.Id, product.T_class, product.T_name, product.T_model, v.T_num, 1)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- o.Rollback()
|
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "更新库存信息失败"}
|
|
|
|
|
- c.ServeJSON()
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if len(needAdd) > 0 {
|
|
if len(needAdd) > 0 {
|
|
|
// 新增入库产品列表
|
|
// 新增入库产品列表
|
|
|
for _, v := range needAdd {
|
|
for _, v := range needAdd {
|
|
|
- product, _ := Basic.Read_Product_ById(v.T_product_id)
|
|
|
|
|
-
|
|
|
|
|
StockOutProduct := Stock.StockOutProduct{
|
|
StockOutProduct := Stock.StockOutProduct{
|
|
|
T_number: T_number,
|
|
T_number: T_number,
|
|
|
T_product_id: v.T_product_id,
|
|
T_product_id: v.T_product_id,
|
|
@@ -3405,21 +3454,11 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // 减少库存
|
|
|
|
|
- _, err = StockDao.AddOrUpdate_Occupy_Stock(StockOut.T_depot_id, product.Id, product.T_class, product.T_name, product.T_model, v.T_num, 2)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- o.Rollback()
|
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: "增加库存失败"}
|
|
|
|
|
- c.ServeJSON()
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
if len(needEdit) > 0 {
|
|
if len(needEdit) > 0 {
|
|
|
for _, v := range needEdit {
|
|
for _, v := range needEdit {
|
|
|
- product, _ := Basic.Read_Product_ById(v.T_product_id)
|
|
|
|
|
StockOutProduct := Stock.StockOutProduct{
|
|
StockOutProduct := Stock.StockOutProduct{
|
|
|
T_number: StockOut.T_number,
|
|
T_number: StockOut.T_number,
|
|
|
T_product_id: v.T_product_id,
|
|
T_product_id: v.T_product_id,
|
|
@@ -3427,27 +3466,6 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
T_num: productNewMap[v.T_product_id].T_num, // 入库数量
|
|
T_num: productNewMap[v.T_product_id].T_num, // 入库数量
|
|
|
T_state: 1,
|
|
T_state: 1,
|
|
|
}
|
|
}
|
|
|
- // 出库数量比之前多,减少库存
|
|
|
|
|
- var T_type int
|
|
|
|
|
- var T_num int
|
|
|
|
|
-
|
|
|
|
|
- if productNewMap[v.T_product_id].T_num > productOldMap[v.T_product_id].T_num {
|
|
|
|
|
- // 减少库存
|
|
|
|
|
- T_type = 2
|
|
|
|
|
- T_num = productNewMap[v.T_product_id].T_num - productOldMap[v.T_product_id].T_num
|
|
|
|
|
- } else {
|
|
|
|
|
- // 增加库存
|
|
|
|
|
- T_type = 1
|
|
|
|
|
- T_num = productOldMap[v.T_product_id].T_num - productNewMap[v.T_product_id].T_num
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- _, err = StockDao.AddOrUpdate_Occupy_Stock(StockOut.T_depot_id, product.Id, product.T_class, product.T_name, product.T_model, T_num, T_type)
|
|
|
|
|
- if err != nil {
|
|
|
|
|
- o.Rollback()
|
|
|
|
|
- c.Data["json"] = lib.JSONS{Code: 203, Msg: err.Error()}
|
|
|
|
|
- c.ServeJSON()
|
|
|
|
|
- return
|
|
|
|
|
- }
|
|
|
|
|
// 更新产品表
|
|
// 更新产品表
|
|
|
err = StockOutProductDao.Update_StockOutProduct(StockOutProduct)
|
|
err = StockOutProductDao.Update_StockOutProduct(StockOutProduct)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
@@ -3463,18 +3481,18 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
if len(T_remark) > 0 {
|
|
if len(T_remark) > 0 {
|
|
|
StockOut.T_remark = T_remark
|
|
StockOut.T_remark = T_remark
|
|
|
}
|
|
}
|
|
|
- if len(T_receive) > 0 {
|
|
|
|
|
- StockOut.T_receive = T_receive
|
|
|
|
|
- }
|
|
|
|
|
if len(T_project) > 0 {
|
|
if len(T_project) > 0 {
|
|
|
StockOut.T_project = T_project
|
|
StockOut.T_project = T_project
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- if len(T_date) > 0 {
|
|
|
|
|
- StockOut.T_date = T_date
|
|
|
|
|
|
|
+ if len(T_company_name) > 0 {
|
|
|
|
|
+ StockOut.T_company_name = T_company_name
|
|
|
|
|
+ }
|
|
|
|
|
+ if len(T_payment_method) > 0 {
|
|
|
|
|
+ StockOut.T_payment_method = T_payment_method
|
|
|
}
|
|
}
|
|
|
|
|
+ StockOut.T_state = Stock.StockOutWaitAudit
|
|
|
|
|
|
|
|
- err = StockOutDao.Update_StockOut(StockOut, "T_remark", "T_receive", "T_project", "T_date")
|
|
|
|
|
|
|
+ err = StockOutDao.Update_StockOut(StockOut, "T_remark", "T_receive", "T_project", "T_company_name", "T_payment_method", "T_state")
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改入库失败"}
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "修改入库失败"}
|
|
@@ -3483,12 +3501,79 @@ func (c *StockController) StockOut_Apply_Edit() {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
o.Commit()
|
|
o.Commit()
|
|
|
- if len(T_date) > 0 && T_old_date != T_date {
|
|
|
|
|
- // 修改出库产品日期
|
|
|
|
|
- StockOutProductDao.Update_StockOutProduct_T_date(StockOut.T_number, T_date)
|
|
|
|
|
|
|
+ NatsServer.AddUserLogs(c.User.T_uuid, "出库申请", "修改", StockOut)
|
|
|
|
|
+
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_number}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+// 删除出库申请
|
|
|
|
|
+func (c *StockController) StockOut_Apply_Del() {
|
|
|
|
|
+
|
|
|
|
|
+ T_number := c.GetString("T_number") // 入库单号
|
|
|
|
|
+
|
|
|
|
|
+ o := orm.NewOrm()
|
|
|
|
|
+ o.Begin()
|
|
|
|
|
+ StockOutDao := Stock.NewStockOut(o)
|
|
|
|
|
+ StockOutProductDao := Stock.NewStockOutProduct(o)
|
|
|
|
|
+ StockDao := Stock.NewStock(o)
|
|
|
|
|
+
|
|
|
|
|
+ // 查询出库信息
|
|
|
|
|
+ stockOut, err := StockOutDao.Read_StockOut_ByT_number(T_number)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "查询失败!"}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
}
|
|
}
|
|
|
|
|
+ // 查询出库产品信息
|
|
|
|
|
+ productOldList := StockOutProductDao.Read_StockOutProduct_List(stockOut.T_number)
|
|
|
|
|
|
|
|
- NatsServer.AddUserLogs(c.User.T_uuid, "出库申请", "修改", StockOut)
|
|
|
|
|
|
|
+ var oldProductList []dto.StockProduct
|
|
|
|
|
+ allProductList := []int{}
|
|
|
|
|
+ for _, product := range productOldList {
|
|
|
|
|
+ oldProductList = append(oldProductList, dto.StockProduct{
|
|
|
|
|
+ T_product_id: product.T_product_id,
|
|
|
|
|
+ T_num: product.T_num,
|
|
|
|
|
+ T_relation_sn: lib.SplitString(product.T_relation_sn, ","),
|
|
|
|
|
+ })
|
|
|
|
|
+ allProductList = append(allProductList, product.T_product_id)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 删除入库产品列表
|
|
|
|
|
+ for _, v := range oldProductList {
|
|
|
|
|
+ product, _ := Basic.Read_Product_ById(v.T_product_id)
|
|
|
|
|
+ // 删除入库产品列表
|
|
|
|
|
+ err = StockOutProductDao.Delete_StockOutProduct(stockOut.T_number, stockOut.T_depot_id, v.T_product_id)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: "删除产品出库信息失败!"}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 减少占用库存
|
|
|
|
|
+ _, err = StockDao.AddOrUpdate_Occupy_Stock(stockOut.T_depot_id, product.Id, product.T_class, product.T_name, product.T_model, v.T_num, 1)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "更新占用库存失败"}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ err = StockOutDao.Delete_StockOut(stockOut)
|
|
|
|
|
+ if err != nil {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 203, Msg: "删除出库失败"}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ o.Commit()
|
|
|
|
|
+
|
|
|
|
|
+ NatsServer.AddUserLogs(c.User.T_uuid, "出库申请", "删除", stockOut)
|
|
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_number}
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_number}
|
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
@@ -3509,6 +3594,7 @@ func (c *StockController) StockOut_Finance_List() {
|
|
|
|
|
|
|
|
// 查询
|
|
// 查询
|
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
|
|
+ T_state, _ := c.GetInt("T_state")
|
|
|
T_contract_number := c.GetString("T_contract_number")
|
|
T_contract_number := c.GetString("T_contract_number")
|
|
|
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")
|
|
@@ -3519,7 +3605,7 @@ func (c *StockController) StockOut_Finance_List() {
|
|
|
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_StockOut_Audit_List(T_name, Stock.StockOutTypeFinance, T_depot_id, T_contract_number, T_start_date, T_end_date, page, page_z)
|
|
|
|
|
|
|
+ R_List, R_cnt := StockOutDao.Read_StockOut_Audit_List("", T_name, Stock.StockOutTypeFinance, T_state, T_depot_id, T_contract_number, T_start_date, T_end_date, 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
|
|
@@ -3546,6 +3632,7 @@ func (c *StockController) StockOut_Manager_List() {
|
|
|
|
|
|
|
|
// 查询
|
|
// 查询
|
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
|
|
+ T_state, _ := c.GetInt("T_state")
|
|
|
T_contract_number := c.GetString("T_contract_number")
|
|
T_contract_number := c.GetString("T_contract_number")
|
|
|
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")
|
|
@@ -3556,7 +3643,7 @@ func (c *StockController) StockOut_Manager_List() {
|
|
|
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_StockOut_Audit_List(T_name, Stock.StockOutTypeManager, T_depot_id, T_contract_number, T_start_date, T_end_date, page, page_z)
|
|
|
|
|
|
|
+ R_List, R_cnt := StockOutDao.Read_StockOut_Audit_List("", T_name, Stock.StockOutTypeManager, T_state, T_depot_id, T_contract_number, T_start_date, T_end_date, 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
|
|
@@ -3583,6 +3670,7 @@ func (c *StockController) StockOut_Warehouse_List() {
|
|
|
|
|
|
|
|
// 查询
|
|
// 查询
|
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
T_depot_id, _ := c.GetInt("T_depot_id")
|
|
|
|
|
+ T_state, _ := c.GetInt("T_state")
|
|
|
T_contract_number := c.GetString("T_contract_number")
|
|
T_contract_number := c.GetString("T_contract_number")
|
|
|
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")
|
|
@@ -3593,7 +3681,7 @@ func (c *StockController) StockOut_Warehouse_List() {
|
|
|
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_StockOut_Audit_List(T_name, Stock.StockOutTypeWarehouse, T_depot_id, T_contract_number, T_start_date, T_end_date, page, page_z)
|
|
|
|
|
|
|
+ R_List, R_cnt := StockOutDao.Read_StockOut_Audit_List(c.User.T_uuid, T_name, Stock.StockOutTypeWarehouse, T_state, T_depot_id, T_contract_number, T_start_date, T_end_date, 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
|
|
@@ -3606,7 +3694,7 @@ func (c *StockController) StockOut_Warehouse_List() {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-// 财务审核
|
|
|
|
|
|
|
+// 财务/总经理审核
|
|
|
func (c *StockController) StockOut_Audit() {
|
|
func (c *StockController) StockOut_Audit() {
|
|
|
|
|
|
|
|
T_number := c.GetString("T_number") // 出库单号
|
|
T_number := c.GetString("T_number") // 出库单号
|
|
@@ -3701,6 +3789,13 @@ func (c *StockController) StockOut_Warehouse() {
|
|
|
product, _ := Basic.Read_Product_ById(product_id)
|
|
product, _ := Basic.Read_Product_ById(product_id)
|
|
|
|
|
|
|
|
num, _ := strconv.Atoi(strings.Split(v, "-")[1])
|
|
num, _ := strconv.Atoi(strings.Split(v, "-")[1])
|
|
|
|
|
+ if num == 0 {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("%s出库数量不能为0!", product.T_name)}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
T_relation_sn := strings.Split(v, "-")[2]
|
|
T_relation_sn := strings.Split(v, "-")[2]
|
|
|
if T_relation_sn == "" && product.T_relation_sn == 1 {
|
|
if T_relation_sn == "" && product.T_relation_sn == 1 {
|
|
|
o.Rollback()
|
|
o.Rollback()
|
|
@@ -3708,9 +3803,18 @@ func (c *StockController) StockOut_Warehouse() {
|
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ snList := strings.Split(T_relation_sn, ",")
|
|
|
|
|
+ if num != len(snList) {
|
|
|
|
|
+ o.Rollback()
|
|
|
|
|
+ c.Data["json"] = lib.JSONS{Code: 202, Msg: fmt.Sprintf("%sSN数量与出库数量不一致,请核查!", product.T_name)}
|
|
|
|
|
+ c.ServeJSON()
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 2、更新设备状态为已出库
|
|
// 2、更新设备状态为已出库
|
|
|
- if len(T_relation_sn) > 0 {
|
|
|
|
|
- snList := strings.Split(T_relation_sn, ",")
|
|
|
|
|
|
|
+ if len(snList) > 0 {
|
|
|
|
|
+
|
|
|
for _, sn := range snList {
|
|
for _, sn := range snList {
|
|
|
mqtt := Stock.Read_MqttUser(sn)
|
|
mqtt := Stock.Read_MqttUser(sn)
|
|
|
device := Stock.Device{
|
|
device := Stock.Device{
|
|
@@ -3742,7 +3846,7 @@ func (c *StockController) StockOut_Warehouse() {
|
|
|
T_num: num, // 出库数量
|
|
T_num: num, // 出库数量
|
|
|
T_date: T_date, // 出库数量
|
|
T_date: T_date, // 出库数量
|
|
|
T_relation_sn: T_relation_sn,
|
|
T_relation_sn: T_relation_sn,
|
|
|
- T_state: 2,
|
|
|
|
|
|
|
+ T_state: 1,
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 更新产品表
|
|
// 更新产品表
|
|
@@ -3754,7 +3858,7 @@ func (c *StockController) StockOut_Warehouse() {
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // 5、更新产品库存列表
|
|
|
|
|
|
|
+ // 5、更新产品库存列表、占用库存
|
|
|
_, err = StockDao.Stock_Warehouse(StockOut.T_depot_id, product.Id, product.T_class, product.T_name, product.T_model, num)
|
|
_, err = StockDao.Stock_Warehouse(StockOut.T_depot_id, product.Id, product.T_class, product.T_name, product.T_model, num)
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
o.Rollback()
|
|
@@ -3764,8 +3868,10 @@ func (c *StockController) StockOut_Warehouse() {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ StockOut.T_warehouse = c.User.T_uuid
|
|
|
StockOut.T_state = Stock.StockOutAlreadyOut
|
|
StockOut.T_state = Stock.StockOutAlreadyOut
|
|
|
- err = StockOutDao.Update_StockOut(StockOut, "T_state")
|
|
|
|
|
|
|
+ StockOut.T_date = T_date
|
|
|
|
|
+ err = StockOutDao.Update_StockOut(StockOut, "T_state", "T_date", "T_warehouse")
|
|
|
if err != nil {
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
o.Rollback()
|
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "出库审批失败"}
|
|
c.Data["json"] = lib.JSONS{Code: 203, Msg: "出库审批失败"}
|
|
@@ -3776,7 +3882,7 @@ func (c *StockController) StockOut_Warehouse() {
|
|
|
o.Commit()
|
|
o.Commit()
|
|
|
StockOut_Edit_StockMonth(StockOut.T_date, StockOut.T_depot_id, allProductList)
|
|
StockOut_Edit_StockMonth(StockOut.T_date, StockOut.T_depot_id, allProductList)
|
|
|
|
|
|
|
|
- NatsServer.AddUserLogs(c.User.T_uuid, "出库申请", "修改", StockOut)
|
|
|
|
|
|
|
+ NatsServer.AddUserLogs(c.User.T_uuid, "出库申请", "出库", StockOut)
|
|
|
|
|
|
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_number}
|
|
c.Data["json"] = lib.JSONS{Code: 200, Msg: "ok!", Data: T_number}
|
|
|
c.ServeJSON()
|
|
c.ServeJSON()
|