商品库存明细接口
This commit is contained in:
@@ -431,6 +431,88 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只根据商品id查询库存数量
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void findStockNumByMaterialId() {
|
||||||
|
try {
|
||||||
|
PageUtil<DepotItem> pageUtil = new PageUtil<DepotItem>();
|
||||||
|
pageUtil.setPageSize(model.getPageSize());
|
||||||
|
pageUtil.setCurPage(model.getPageNo());
|
||||||
|
pageUtil.setAdvSearch(getConditionById());
|
||||||
|
depotItemService.find(pageUtil);
|
||||||
|
List<DepotItem> dataList = pageUtil.getPageList();
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
outer.put("total", pageUtil.getTotalCount());
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if(null != dataList) {
|
||||||
|
for(DepotItem depotItem:dataList) {
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
Integer InSum = sumNumberByMaterialId("入库", depotItem.getMaterialId().getId());
|
||||||
|
Integer OutSum = sumNumberByMaterialId("出库", depotItem.getMaterialId().getId());
|
||||||
|
item.put("MaterialId", depotItem.getMaterialId()==null?"":depotItem.getMaterialId().getId());
|
||||||
|
item.put("MaterialName", depotItem.getMaterialId().getName());
|
||||||
|
item.put("MaterialModel", depotItem.getMaterialId().getModel());
|
||||||
|
item.put("thisSum", InSum - OutSum);
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outer.put("rows", dataArray);
|
||||||
|
//回写查询结果
|
||||||
|
toClient(outer.toString());
|
||||||
|
}
|
||||||
|
catch (DataAccessException e)
|
||||||
|
{
|
||||||
|
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>查找信息异常", e);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 只根据商品id查询单据列表
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public void findDetailByTypeAndMaterialId() {
|
||||||
|
try {
|
||||||
|
PageUtil pageUtil = new PageUtil();
|
||||||
|
pageUtil.setPageSize(model.getPageSize());
|
||||||
|
pageUtil.setCurPage(model.getPageNo());
|
||||||
|
Long mId = model.getMaterialId();
|
||||||
|
depotItemService.findDetailByTypeAndMaterialId(pageUtil, mId);
|
||||||
|
List dataList = pageUtil.getPageList();
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
outer.put("total", pageUtil.getTotalCount());
|
||||||
|
//存放数据json数组
|
||||||
|
JSONArray dataArray = new JSONArray();
|
||||||
|
if(dataList!=null){
|
||||||
|
for(Integer i=0; i<dataList.size(); i++){
|
||||||
|
JSONObject item = new JSONObject();
|
||||||
|
Object dl = dataList.get(i); //获取对象
|
||||||
|
Object[] arr = (Object[]) dl; //转为数组
|
||||||
|
item.put("Number", arr[0]); //商品编号
|
||||||
|
item.put("Type", arr[1]); //进出类型
|
||||||
|
item.put("BasicNumber", arr[2]); //数量
|
||||||
|
item.put("OperTime", arr[3]); //时间
|
||||||
|
dataArray.add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
outer.put("rows", dataArray);
|
||||||
|
//回写查询结果
|
||||||
|
toClient(outer.toString());
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
Log.errorFileSync(">>>>>>>>>>>>>>>>>>>回写查询信息结果异常", e);
|
||||||
|
}
|
||||||
|
catch (JshException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找礼品卡信息
|
* 查找礼品卡信息
|
||||||
* @return
|
* @return
|
||||||
@@ -728,6 +810,35 @@ public class DepotItemAction extends BaseAction<DepotItemModel>
|
|||||||
return sumNumber;
|
return sumNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仅根据商品Id进行数量合计
|
||||||
|
* @param type
|
||||||
|
* @param MId
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Integer sumNumberByMaterialId(String type,Long MId) {
|
||||||
|
Integer sumNumber = 0;
|
||||||
|
String allNumber = "";
|
||||||
|
PageUtil pageUtil = new PageUtil();
|
||||||
|
pageUtil.setPageSize(0);
|
||||||
|
pageUtil.setCurPage(0);
|
||||||
|
try {
|
||||||
|
depotItemService.findByTypeAndMaterialId(pageUtil, type, MId);
|
||||||
|
allNumber = pageUtil.getPageList().toString();
|
||||||
|
allNumber = allNumber.substring(1,allNumber.length()-1);
|
||||||
|
if(allNumber.equals("null")){
|
||||||
|
allNumber = "0";
|
||||||
|
}
|
||||||
|
allNumber = allNumber.replace(".0", "");
|
||||||
|
} catch (JshException e) {
|
||||||
|
// TODO Auto-generated catch block
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
sumNumber = Integer.parseInt(allNumber);
|
||||||
|
return sumNumber;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 数量合计-礼品卡
|
* 数量合计-礼品卡
|
||||||
* @param type
|
* @param type
|
||||||
|
|||||||
@@ -23,8 +23,7 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
|||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void findByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId,String MonthTime,Boolean isPrev) throws JshException
|
public void findByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId,String MonthTime,Boolean isPrev) throws JshException {
|
||||||
{
|
|
||||||
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||||
Query query;
|
Query query;
|
||||||
StringBuffer queryString = new StringBuffer();
|
StringBuffer queryString = new StringBuffer();
|
||||||
@@ -48,6 +47,42 @@ public class DepotItemDAO extends BaseDAO<DepotItem> implements DepotItemIDAO
|
|||||||
pageUtil.setPageList(query.list());
|
pageUtil.setPageList(query.list());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil,String type,Long MId) throws JshException {
|
||||||
|
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||||
|
Query query;
|
||||||
|
StringBuffer queryString = new StringBuffer();
|
||||||
|
if(type.equals("入库")) {
|
||||||
|
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='" + type +"'");
|
||||||
|
queryString.append(" and MaterialId ="+ MId);
|
||||||
|
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
queryString.append("select sum(BasicNumber) as BasicNumber from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='" + type +"'");
|
||||||
|
queryString.append(" and SubType!='调拨' and SubType!='礼品充值' and MaterialId ="+ MId);
|
||||||
|
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||||
|
}
|
||||||
|
pageUtil.setTotalCount(query.list().size());
|
||||||
|
pageUtil.setPageList(query.list());
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void findDetailByTypeAndMaterialId(PageUtil<DepotItem> pageUtil,Long MId) throws JshException {
|
||||||
|
//多表联查,多表连查,此处用到了createSQLQuery,可以随便写sql语句,很方便
|
||||||
|
Query query;
|
||||||
|
StringBuffer queryString = new StringBuffer();
|
||||||
|
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,di.BasicNumber,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='入库' ");
|
||||||
|
queryString.append(" and MaterialId ="+ MId);
|
||||||
|
queryString.append(" union all ");
|
||||||
|
queryString.append("select dh.Number,concat(dh.SubType,dh.Type) as newType,0-di.BasicNumber,date_format(dh.OperTime,'%Y-%m-%d %H:%i:%S') as oTime from jsh_depothead dh INNER JOIN jsh_depotitem di on dh.id=di.HeaderId where type='出库' ");
|
||||||
|
queryString.append(" and SubType!='调拨' and SubType!='礼品充值' and MaterialId ="+ MId);
|
||||||
|
query = this.getHibernateTemplate().getSessionFactory().getCurrentSession().createSQLQuery(queryString + SearchConditionUtil.getCondition(pageUtil.getAdvSearch()));
|
||||||
|
pageUtil.setTotalCount(query.list().size());
|
||||||
|
pageUtil.setPageList(query.list());
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void findPriceByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId,String MonthTime,Boolean isPrev) throws JshException
|
public void findPriceByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId,String MonthTime,Boolean isPrev) throws JshException
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ public interface DepotItemIDAO extends BaseIDAO<DepotItem>
|
|||||||
{
|
{
|
||||||
public void findByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId, String MonthTime,Boolean isPrev) throws JshException;
|
public void findByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId, String MonthTime,Boolean isPrev) throws JshException;
|
||||||
|
|
||||||
|
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil,String type,Long MId) throws JshException;
|
||||||
|
|
||||||
|
public void findDetailByTypeAndMaterialId(PageUtil<DepotItem> pageUtil,Long MId) throws JshException;
|
||||||
|
|
||||||
public void findPriceByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId, String MonthTime,Boolean isPrev) throws JshException;
|
public void findPriceByType(PageUtil<DepotItem> pageUtil,String type,Integer ProjectId,Long MId, String MonthTime,Boolean isPrev) throws JshException;
|
||||||
|
|
||||||
public void buyOrSale(PageUtil<DepotItem> pageUtil,String type, String subType,Long MId, String MonthTime, String sumType) throws JshException;
|
public void buyOrSale(PageUtil<DepotItem> pageUtil,String type, String subType,Long MId, String MonthTime, String sumType) throws JshException;
|
||||||
|
|||||||
@@ -16,6 +16,10 @@ public interface DepotItemIService extends BaseIService<DepotItem>
|
|||||||
{
|
{
|
||||||
void findByType(PageUtil<DepotItem> depotItem, String type,Integer ProjectId, Long MId, String MonthTime,Boolean isPrev)throws JshException;
|
void findByType(PageUtil<DepotItem> depotItem, String type,Integer ProjectId, Long MId, String MonthTime,Boolean isPrev)throws JshException;
|
||||||
|
|
||||||
|
void findByTypeAndMaterialId(PageUtil<DepotItem> depotItem, String type, Long MId)throws JshException;
|
||||||
|
|
||||||
|
void findDetailByTypeAndMaterialId(PageUtil<DepotItem> depotItem, Long MId)throws JshException;
|
||||||
|
|
||||||
void findPriceByType(PageUtil<DepotItem> depotItem, String type,Integer ProjectId, Long MId, String MonthTime,Boolean isPrev)throws JshException;
|
void findPriceByType(PageUtil<DepotItem> depotItem, String type,Integer ProjectId, Long MId, String MonthTime,Boolean isPrev)throws JshException;
|
||||||
|
|
||||||
void buyOrSale(PageUtil<DepotItem> depotItem, String type, String subType, Long MId, String MonthTime, String sumType)throws JshException;
|
void buyOrSale(PageUtil<DepotItem> depotItem, String type, String subType, Long MId, String MonthTime, String sumType)throws JshException;
|
||||||
|
|||||||
@@ -50,6 +50,18 @@ public class DepotItemService extends BaseService<DepotItem> implements DepotIte
|
|||||||
depotItemDao.findByType(pageUtil, type, ProjectId, MId, MonthTime,isPrev);
|
depotItemDao.findByType(pageUtil, type, ProjectId, MId, MonthTime,isPrev);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void findByTypeAndMaterialId(PageUtil<DepotItem> pageUtil, String type,Long MId) throws JshException
|
||||||
|
{
|
||||||
|
depotItemDao.findByTypeAndMaterialId(pageUtil, type, MId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void findDetailByTypeAndMaterialId(PageUtil<DepotItem> pageUtil,Long MId) throws JshException
|
||||||
|
{
|
||||||
|
depotItemDao.findDetailByTypeAndMaterialId(pageUtil, MId);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void findPriceByType(PageUtil<DepotItem> pageUtil, String type,Integer ProjectId,Long MId, String MonthTime,Boolean isPrev) throws JshException
|
public void findPriceByType(PageUtil<DepotItem> pageUtil, String type,Integer ProjectId,Long MId, String MonthTime,Boolean isPrev) throws JshException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -612,7 +612,7 @@
|
|||||||
//查询库存
|
//查询库存
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "get",
|
type: "get",
|
||||||
url: '<%=path %>/depotItem/findStockNumById.action',
|
url: '<%=path %>/depotItem/findStockNumByMaterialId.action',
|
||||||
data: {
|
data: {
|
||||||
MaterialId: mId,
|
MaterialId: mId,
|
||||||
MonthTime: monthTime
|
MonthTime: monthTime
|
||||||
|
|||||||
Reference in New Issue
Block a user