|
|
@@ -157,6 +157,9 @@ func (r *ErmcpAreaStockApply) buildSql() string {
|
|
|
if len(r.FilterStatus) > 0 {
|
|
|
sqlId.Join(fmt.Sprintf(" and t.APPLYSTATUS in(%v)", r.FilterStatus))
|
|
|
}
|
|
|
+
|
|
|
+ // 排序
|
|
|
+ sqlId.Join(" order by t.APPLYTIME desc")
|
|
|
return sqlId.String()
|
|
|
}
|
|
|
|
|
|
@@ -206,3 +209,84 @@ func (r *ErmcpAreaStockApplySum) GetDataEx() (interface{}, error) {
|
|
|
err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
return sData, err
|
|
|
}
|
|
|
+
|
|
|
+// ErmcpAreaStock 机构库存表
|
|
|
+type ErmcpAreaStock struct {
|
|
|
+ TODAYBUYINQTY float64 `json:"todaybuyinqty" xorm:"'TODAYBUYINQTY'"` // 今日采购入库量
|
|
|
+ TODAYPRODUCEINQTY float64 `json:"todayproduceinqty" xorm:"'TODAYPRODUCEINQTY'"` // 今日生产入库量
|
|
|
+ TODAYSELLOUTQTY float64 `json:"todayselloutqty" xorm:"'TODAYSELLOUTQTY'"` // 今日销售出库量
|
|
|
+ TODAYPRODUCEOUTQTY float64 `json:"todayproduceoutqty" xorm:"'TODAYPRODUCEOUTQTY'"` // 今日生产出库量
|
|
|
+ UPDATETIME string `json:"updatetime" xorm:"'UPDATETIME'"` // 更新时间
|
|
|
+ USERID int64 `json:"userid" xorm:"'USERID'"` // 机构ID
|
|
|
+ WRSTANDARDID string `json:"wrstandardid" xorm:"'WRSTANDARDID'"` // 现货商品ID
|
|
|
+ SPOTGOODSMODELID int32 `json:"spotgoodsmodelid" xorm:"'SPOTGOODSMODELID'"` // 现货型号ID
|
|
|
+ SPOTGOODSBRANDID int32 `json:"spotgoodsbrandid" xorm:"'SPOTGOODSBRANDID'"` // 现货品牌ID
|
|
|
+ WAREHOUSEINFOID string `json:"warehouseinfoid" xorm:"'WAREHOUSEINFOID'"` // 仓库ID
|
|
|
+ DELIVERYGOODSID int64 `json:"deliverygoodsid" xorm:"'DELIVERYGOODSID'"` // 现货品种ID
|
|
|
+ ORISTOCK float64 `json:"oristock" xorm:"'ORISTOCK'"` // 期初库存量(昨日量)
|
|
|
+ CURSTOCK float64 `json:"curstock" xorm:"'CURSTOCK'"` // 期末库存量(今日量)
|
|
|
+ WRSTANDARDNAME string `json:"wrstandardname" xorm:"'WRSTANDARDNAME'"` // 现货商品名称
|
|
|
+ WRSTANDARDCODE string `json:"wrstandardcode" xorm:"'WRSTANDARDCODE'"` // 现货商品代码
|
|
|
+ UNITID int32 `json:"unitid" xorm:"'UNITID'"` // 单位id
|
|
|
+ BRANDNAME string `json:"brandname" xorm:"'BRANDNAME'"` // 品牌名称
|
|
|
+ MODELNAME string `json:"modelname" xorm:"'MODELNAME'"` // 型号名称
|
|
|
+ WAREHOUSENAME string `json:"warehousename" xorm:"'WAREHOUSENAME'"` // 仓库名称
|
|
|
+ WAREHOUSECODE string `json:"warehousecode" xorm:"'WAREHOUSECODE'"` // 仓库代码
|
|
|
+ WAREHOUSETYPE int32 `json:"warehousetype" xorm:"'WAREHOUSETYPE'"` // 仓库类型 - 1 厂库 2 自有库 3 合作库
|
|
|
+ USERNAME string `json:"username"` // 机构名称
|
|
|
+ ENUMDICNAME string `json:"enumdicname"` // 单位名称
|
|
|
+}
|
|
|
+
|
|
|
+func (r *ErmcpAreaStock) calc() {
|
|
|
+ r.USERNAME = mtpcache.GetUserNameByUserId(r.USERID)
|
|
|
+ r.ENUMDICNAME = mtpcache.GetEnumDicitemName(r.UNITID)
|
|
|
+}
|
|
|
+
|
|
|
+func (r *ErmcpAreaStock) buildSql() string {
|
|
|
+ var sqlId utils.SQLVal = "SELECT t.TODAYBUYINQTY," +
|
|
|
+ " t.TODAYPRODUCEINQTY," +
|
|
|
+ " t.TODAYSELLOUTQTY," +
|
|
|
+ " t.TODAYPRODUCEOUTQTY," +
|
|
|
+ " to_char(t.UPDATETIME, 'yyyy-mm-dd hh24:mi:ss') UPDATETIME," +
|
|
|
+ " t.USERID," +
|
|
|
+ " t.WRSTANDARDID," +
|
|
|
+ " t.SPOTGOODSMODELID," +
|
|
|
+ " t.SPOTGOODSBRANDID," +
|
|
|
+ " t.WAREHOUSEINFOID," +
|
|
|
+ " t.DELIVERYGOODSID," +
|
|
|
+ " t.ORISTOCK," +
|
|
|
+ " t.CURSTOCK," +
|
|
|
+ " w.wrstandardname," +
|
|
|
+ " w.wrstandardcode," +
|
|
|
+ " w.unitid," +
|
|
|
+ " gb.brandname," +
|
|
|
+ " gm.modelname," +
|
|
|
+ " h.warehousename," +
|
|
|
+ " h.warehousecode," +
|
|
|
+ " h.warehousetype" +
|
|
|
+ " FROM ERMCP_AREASTOCK t" +
|
|
|
+ " LEFT JOIN WRSTANDARD w" +
|
|
|
+ " on t.wrstandardid = w.wrstandardid" +
|
|
|
+ " LEFT JOIN SPOTGOODSBRAND gb" +
|
|
|
+ " on t.spotgoodsbrandid = gb.brandid" +
|
|
|
+ " LEFT JOIN SPOTGOODSMODEL gm" +
|
|
|
+ " on t.spotgoodsmodelid = gm.modelid" +
|
|
|
+ " LEFT JOIN WAREHOUSEINFO h" +
|
|
|
+ " on t.warehouseinfoid = h.autoid" +
|
|
|
+ " WHERE 1 = 1"
|
|
|
+ sqlId.And("t.USERID", r.USERID)
|
|
|
+ sqlId.Join(" order by t.WRSTANDARDID, t.UPDATETIME desc")
|
|
|
+ return sqlId.String()
|
|
|
+}
|
|
|
+
|
|
|
+// GetDataEx 获取机构库存信息
|
|
|
+func (r *ErmcpAreaStock) GetDataEx() (interface{}, error) {
|
|
|
+ sData := make([]ErmcpAreaStock, 0)
|
|
|
+ err := db.GetEngine().SQL(r.buildSql()).Find(&sData)
|
|
|
+ if err == nil {
|
|
|
+ for i := range sData {
|
|
|
+ sData[i].calc()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return sData, err
|
|
|
+}
|