Ejemplo n.º 1
0
 /**
  * @param id
  * @return
  */
 @Override
 public AjaxJson getItemInfoById(String id, String tranType, String stockId, String batchNo) {
   AjaxJson j = new AjaxJson();
   Map<String, Object> attributes = new HashMap<String, Object>();
   TScIcitemEntity icitemEntity = this.getEntity(TScIcitemEntity.class, id);
   // 配置默认仓库
   if (null != icitemEntity.getStockForIcitemEntity()) {
     attributes.put("stockId", icitemEntity.getStockForIcitemEntity().getId());
     attributes.put("stockName", icitemEntity.getStockForIcitemEntity().getName());
   } else {
     attributes.put("stockId", "");
     attributes.put("stockName", "");
   }
   List<TScItemPriceEntity> priceEntityList =
       this.findHql("from TScItemPriceEntity where itemID = ?", new Object[] {id});
   for (TScItemPriceEntity price : priceEntityList) {
     if ("51".equals(tranType)) {
       if (null != price.getDefaultCG() && 1 == price.getDefaultCG()) {
         attributes.put("unitId", price.getId());
         attributes.put(
             "unitName",
             price.getMeasureunitToIcItemEntity() == null
                 ? ""
                 : price.getMeasureunitToIcItemEntity().getName());
         attributes.put("cofficient", price.getCoefficient());
         attributes.put("barCode", price.getBarCode());
         // 采购限价
         attributes.put("cgLimitPrice", price.getCgLimitPrice());
         // 销货限价
         attributes.put("xsLimitPrice", price.getXsLimitPrice());
       }
     } else if ("52".equals(tranType) || "53".equals(tranType)) {
       if (null != price.getDefaultCK() && 1 == price.getDefaultCK()) {
         attributes.put("unitId", price.getId());
         attributes.put(
             "unitName",
             price.getMeasureunitToIcItemEntity() == null
                 ? ""
                 : price.getMeasureunitToIcItemEntity().getName());
         attributes.put("cofficient", price.getCoefficient());
         attributes.put("barCode", price.getBarCode());
         // 限购单价
         attributes.put("cgLimitPrice", price.getCgLimitPrice());
         // 销货限价
         attributes.put("xsLimitPrice", price.getXsLimitPrice());
       }
     } else if ("1504".equals(tranType) || "353".equals(tranType)) {
       if (null != price.getDefaultCK() && 1 == price.getDefaultCK()) {
         attributes.put(
             "unitName",
             price.getMeasureunitToIcItemEntity() == null
                 ? ""
                 : price.getMeasureunitToIcItemEntity().getName()); // 单位名称
         attributes.put("barCode", price.getBarCode()); // 条形码
         attributes.put("unitID", price.getId()); // 单位
         attributes.put("basicUnitID", price.getId()); // 基本单位
         attributes.put("coefficient", price.getCoefficient()); // 换算率
       }
     } else if ("103".equals(tranType) || "1506".equals(tranType)) {
       if (null != price.getDefaultXS() && 1 == price.getDefaultXS()) {
         attributes.put("unitId", price.getId());
         if (null != price.getMeasureunitToIcItemEntity()) {
           attributes.put(
               "unitName",
               price.getMeasureunitToIcItemEntity() == null
                   ? ""
                   : price.getMeasureunitToIcItemEntity().getName());
         }
         attributes.put("cofficient", price.getCoefficient());
         attributes.put("barCode", price.getBarCode());
         // 限购单价
         attributes.put("cgLimitPrice", price.getCgLimitPrice());
         // 销货限价
         attributes.put("xsLimitPrice", price.getXsLimitPrice());
       }
     }
     // 辅助单位
     if ("0003".equals(price.getUnitType())) {
       attributes.put("secUnitId", price.getId());
       attributes.put("secCoefficient", price.getCoefficient());
     }
     // 基本单位
     else if ("0001".equals(price.getUnitType())) {
       attributes.put("basicUnitId", price.getId());
       attributes.put("basicCoefficient", price.getCoefficient());
     }
   }
   attributes.put("id", id);
   if (StringUtils.isNotEmpty(stockId)) {
     // 获取库存基本信息;
     List<TScIcInventoryEntity> inventoryEntity =
         this.findHql(
             "from TScIcInventoryEntity where itemId = ? and stockId = ?",
             new Object[] {id, stockId});
     // 若存在库存数据,则判断是否存在批号数据,若不存在,则取库存数量为商品限量,若存在,则取该批号的库存数量作为商品限量
     if (inventoryEntity.size() > 0) {
       if (StringUtils.isEmpty(batchNo)) {
         attributes.put("invQty", inventoryEntity.get(0).getBasicQty());
       } else {
         List<TScIcInventoryBatchnoEntity> batchnoEntityList =
             this.findHql(
                 "from TScIcInventoryBatchnoEntity where itemId = ? and stockId=? and batchNo = ?",
                 new Object[] {id, stockId, batchNo});
         if (batchnoEntityList.size() > 0) {
           attributes.put("invQty", batchnoEntityList.get(0).getBasicQty());
         } else {
           attributes.put("invQty", inventoryEntity.get(0).getBasicQty());
         }
       }
     } else {
       attributes.put("invQty", 0);
     }
   } else {
     attributes.put("invQty", 0);
   }
   j.setAttributes(attributes);
   return j;
 }