日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

初始化库存

發(fā)布時(shí)間:2024/1/17 编程问答 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 初始化库存 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>

思路

  • 先來(lái)理一下思路哈~~~
  • 大概就是,新增商品之后,要設(shè)置初始庫(kù)存,添加商品部分已經(jīng)寫好,我只負(fù)責(zé)初始化庫(kù)存,以及將沒(méi)有入庫(kù)的商品添加進(jìn)去
  • 進(jìn)行判斷,如果已經(jīng)入庫(kù),則不需要重復(fù)添加,只添加不存在的
  • 輸入數(shù)字設(shè)置為初始庫(kù)存,沒(méi)有初始則設(shè)置為0

前端頁(yè)面:

<div class="xuanz"><div class="xuanz_in_in"><span class="cx" ng-click="initInventory()">初始化庫(kù)存&nbsp;<span class="caret"></span></span></div><input class="in_l" type="text" placeholder="請(qǐng)輸入初始化庫(kù)存數(shù)" ng-model="realinventory"/><span class="searchbutton in_r" ng-click="search()"></span></div>

controller.js

scope.initInventory = function(){console.log(scope.realinventory);productService.initInventory(scope.realinventory,function(data){//window.location.href=ctx+'/product/index#/inventory/0';scope.list();});}

service.js

initInventory:function(realinventory,callback){$http({method: "POST",url: ctx + "/productinventory/insertprotoproinventory",data:{"realinventory":realinventory}}).success(function (data, status) {callback(data);});}

controller:

/** 將Product信息添加至ProductInventory* 顯示所有* */@RequestMapping(value = "insertprotoproinventory",method = RequestMethod.POST)@ResponseBodypublic Result insertProtoProInventory(@RequestBody ProductInventory productInventory){String appid = (String) SecurityUtils.getSubject().getSession().getAttribute(IConstants.APPIDSESSION);if(appid!=null){productInventory.setAppid(appid);}ShiroDbRealm.ShiroUser user = getCurrentUser();if(Commons.isNull(user)){return new Result(Result.Status.ERROR,null);}Administrator admin = administratorService.queryById(user.getId());if(Commons.isNull(admin) || Commons.isNull(admin.getType())){return new Result(Result.Status.ERROR,null);}if (admin.getType() == 3) {productInventory.setSupplierid(admin.getId());} else if (admin.getType() == 4) {if (!Commons.isNull(admin.getSupplierid())) {productInventory.setSupplierid(Long.valueOf(admin.getSupplierid()));} else {return new Result(Result.Status.ERROR, null);}}if (productInventory.getRealinventory()==null){productInventory.setRealinventory(0);}else {productInventory.getRealinventory();} // productInventory.setRealinventory(realinventory);productInventoryService.insertProductInventory(productInventory);return new Result(Result.Status.OK);}

mapper

<select id="selectByProid" resultMap="BaseResultMap" parameterType="java.lang.Long">select<include refid="Base_Column_List"/>from<include refid="table"/>where proid=#{proid}</select>

serviceImpl

@Overridepublic void insertProductInventory(ProductInventory productInventory) { // Map<String,Object> map = new HashMap<>(); // map.put("appid", productInventory.getAppid()); // map.put("appid", productInventory.getAppid());ProductQuery query = new ProductQuery();query.setAppid(productInventory.getAppid());query.setSupplier(productInventory.getSupplierid());List<Product> productList = productService.queryList(query);//判斷數(shù)據(jù)庫(kù)是否已經(jīng)存在數(shù)據(jù)for (Product product : productList) {long proid = product.getId();if (this.selectByProid(proid) == null) {productInventory.setId(null);productInventory.setAppid(product.getAppid());productInventory.setProid(product.getId());productInventory.setProseries(product.getProductseries());productInventory.setSupplierid(product.getSupplier());productInventory.setFatherid(null);productInventory.setUserid(null);productInventory.setCreatetime(new Date());productInventory.setRealinventory(productInventory.getRealinventory());productInventory.setSupplierinventory(productInventory.getRealinventory());productInventory.setChannelinventory(0);productInventory.setTicketinventory(0);productInventoryDao.insert(productInventory);}else { continue; }}}

DaoImpl

@Overridepublic ProductInventory selectByProid(long proid) {return sqlSessionTemplate.selectOne(getSqlName("selectByProid"),proid);}

轉(zhuǎn)載于:https://my.oschina.net/LYQ19941105/blog/753068

創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來(lái)咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)

總結(jié)

以上是生活随笔為你收集整理的初始化库存的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。