增加商品库存报表
This commit is contained in:
@@ -327,6 +327,7 @@ INSERT INTO `jsh_function` VALUES ('242', '060301', '销售订单', '0603', '/bi
|
|||||||
INSERT INTO `jsh_function` VALUES ('243', '000108', '机构管理', '0001', '/system/organization', '/system/OrganizationList', '', '0150', '', '电脑版', '1', 'profile', '0');
|
INSERT INTO `jsh_function` VALUES ('243', '000108', '机构管理', '0001', '/system/organization', '/system/OrganizationList', '', '0150', '', '电脑版', '1', 'profile', '0');
|
||||||
INSERT INTO `jsh_function` VALUES ('244', '030112', '库存预警', '0301', '/report/stock_warning_report', '/report/StockWarningReport', '\0', '0670', '', '电脑版', '', 'profile', '0');
|
INSERT INTO `jsh_function` VALUES ('244', '030112', '库存预警', '0301', '/report/stock_warning_report', '/report/StockWarningReport', '\0', '0670', '', '电脑版', '', 'profile', '0');
|
||||||
INSERT INTO `jsh_function` VALUES ('245', '000107', '插件管理', '0001', '/system/plugin', '/system/PluginList', '\0', '0170', '', '电脑版', '1', 'profile', '0');
|
INSERT INTO `jsh_function` VALUES ('245', '000107', '插件管理', '0001', '/system/plugin', '/system/PluginList', '\0', '0170', '', '电脑版', '1', 'profile', '0');
|
||||||
|
INSERT INTO `jsh_function` VALUES ('246', '030113', '商品库存', '0301', '/report/material_stock', '/report/MaterialStock', '\0', '0605', '', '电脑版', '', 'profile', '0');
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- Table structure for jsh_in_out_item
|
-- Table structure for jsh_in_out_item
|
||||||
|
|||||||
@@ -1084,3 +1084,17 @@ INSERT INTO `jsh_function` (`id`, `number`, `name`, `parent_number`, `url`, `com
|
|||||||
-- 更新jsh_platform_config数据
|
-- 更新jsh_platform_config数据
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
INSERT INTO `jsh_platform_config` (`id`, `platform_key`, `platform_key_info`, `platform_value`) VALUES ('3', 'platform_url', '官方网站', 'http://www.huaxiaerp.com/');
|
INSERT INTO `jsh_platform_config` (`id`, `platform_key`, `platform_key_info`, `platform_value`) VALUES ('3', 'platform_url', '官方网站', 'http://www.huaxiaerp.com/');
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
-- 时间 2021年6月20日
|
||||||
|
-- by jishenghua
|
||||||
|
-- 将库存状态报表改为进销存统计报表
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
update jsh_function set name='进销存统计', sort='0658' where id=59
|
||||||
|
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
-- 时间 2021年6月20日
|
||||||
|
-- by jishenghua
|
||||||
|
-- 增加商品库存报表
|
||||||
|
-- --------------------------------------------------------
|
||||||
|
INSERT INTO `jsh_function` (`id`, `number`, `name`, `parent_number`, `url`, `component`, `state`, `sort`, `enabled`, `type`, `push_btn`, `icon`, `delete_flag`) VALUES ('246', '030113', '商品库存', '0301', '/report/material_stock', '/report/MaterialStock', b'0', '0605', b'1', '电脑版', '', 'profile', '0');
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.jsh.erp.constants.BusinessConstants;
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
import com.jsh.erp.constants.ExceptionConstants;
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
import com.jsh.erp.datasource.entities.DepotEx;
|
import com.jsh.erp.datasource.entities.DepotEx;
|
||||||
|
import com.jsh.erp.datasource.entities.DepotItemVo4WithInfoEx;
|
||||||
import com.jsh.erp.datasource.entities.Material;
|
import com.jsh.erp.datasource.entities.Material;
|
||||||
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
import com.jsh.erp.datasource.entities.MaterialVo4Unit;
|
||||||
import com.jsh.erp.exception.BusinessRunTimeException;
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
@@ -484,4 +485,50 @@ public class MaterialController {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品库存查询
|
||||||
|
* @param currentPage
|
||||||
|
* @param pageSize
|
||||||
|
* @param depotId
|
||||||
|
* @param categoryId
|
||||||
|
* @param materialParam
|
||||||
|
* @param mpList
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "/getListWithStock")
|
||||||
|
public BaseResponseInfo getListWithStock(@RequestParam("currentPage") Integer currentPage,
|
||||||
|
@RequestParam("pageSize") Integer pageSize,
|
||||||
|
@RequestParam("depotId") Long depotId,
|
||||||
|
@RequestParam("categoryId") Long categoryId,
|
||||||
|
@RequestParam("materialParam") String materialParam,
|
||||||
|
@RequestParam("mpList") String mpList,
|
||||||
|
HttpServletRequest request)throws Exception {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
try {
|
||||||
|
List<Long> idList = new ArrayList<>();
|
||||||
|
if(categoryId != null){
|
||||||
|
idList = materialService.getListByParentId(categoryId);
|
||||||
|
}
|
||||||
|
List<MaterialVo4Unit> dataList = materialService.getListWithStock(depotId, idList, StringUtil.toNull(materialParam),
|
||||||
|
(currentPage-1)*pageSize, pageSize);
|
||||||
|
int total = materialService.getListWithStockCount(depotId, idList, StringUtil.toNull(materialParam));
|
||||||
|
MaterialVo4Unit materialVo4Unit= materialService.getTotalStockAndPrice(depotId, idList, StringUtil.toNull(materialParam));
|
||||||
|
map.put("total", total);
|
||||||
|
map.put("currentStock", materialVo4Unit.getCurrentStock());
|
||||||
|
map.put("currentStockPrice", materialVo4Unit.getCurrentStockPrice());
|
||||||
|
//存放数据json数组
|
||||||
|
map.put("rows", dataList);
|
||||||
|
res.code = 200;
|
||||||
|
res.data = map;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ public class MaterialVo4Unit extends Material{
|
|||||||
|
|
||||||
private Long meId;
|
private Long meId;
|
||||||
|
|
||||||
|
private BigDecimal initialStock;
|
||||||
|
|
||||||
|
private BigDecimal currentStock;
|
||||||
|
|
||||||
|
private BigDecimal currentStockPrice;
|
||||||
|
|
||||||
public String getUnitName() {
|
public String getUnitName() {
|
||||||
return unitName;
|
return unitName;
|
||||||
}
|
}
|
||||||
@@ -123,4 +129,28 @@ public class MaterialVo4Unit extends Material{
|
|||||||
public void setMeId(Long meId) {
|
public void setMeId(Long meId) {
|
||||||
this.meId = meId;
|
this.meId = meId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BigDecimal getInitialStock() {
|
||||||
|
return initialStock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInitialStock(BigDecimal initialStock) {
|
||||||
|
this.initialStock = initialStock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCurrentStock() {
|
||||||
|
return currentStock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentStock(BigDecimal currentStock) {
|
||||||
|
this.currentStock = currentStock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCurrentStockPrice() {
|
||||||
|
return currentStockPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentStockPrice(BigDecimal currentStockPrice) {
|
||||||
|
this.currentStockPrice = currentStockPrice;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -85,4 +85,21 @@ public interface MaterialMapperEx {
|
|||||||
int setUnitIdToNull(@Param("id") Long id);
|
int setUnitIdToNull(@Param("id") Long id);
|
||||||
|
|
||||||
List<MaterialVo4Unit> getMaterialByBarCode(@Param("barCode") String barCode);
|
List<MaterialVo4Unit> getMaterialByBarCode(@Param("barCode") String barCode);
|
||||||
|
|
||||||
|
List<MaterialVo4Unit> getListWithStock(
|
||||||
|
@Param("depotId") Long depotId,
|
||||||
|
@Param("idList") List<Long> idList,
|
||||||
|
@Param("materialParam") String materialParam,
|
||||||
|
@Param("offset") Integer offset,
|
||||||
|
@Param("rows") Integer rows);
|
||||||
|
|
||||||
|
int getListWithStockCount(
|
||||||
|
@Param("depotId") Long depotId,
|
||||||
|
@Param("idList") List<Long> idList,
|
||||||
|
@Param("materialParam") String materialParam);
|
||||||
|
|
||||||
|
MaterialVo4Unit getTotalStockAndPrice(
|
||||||
|
@Param("depotId") Long depotId,
|
||||||
|
@Param("idList") List<Long> idList,
|
||||||
|
@Param("materialParam") String materialParam);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -797,4 +797,16 @@ public class MaterialService {
|
|||||||
public List<MaterialVo4Unit> getMaterialByBarCode(String barCode) {
|
public List<MaterialVo4Unit> getMaterialByBarCode(String barCode) {
|
||||||
return materialMapperEx.getMaterialByBarCode(barCode);
|
return materialMapperEx.getMaterialByBarCode(barCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<MaterialVo4Unit> getListWithStock(Long depotId, List<Long> idList, String materialParam, Integer offset, Integer rows) {
|
||||||
|
return materialMapperEx.getListWithStock(depotId, idList, materialParam, offset, rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getListWithStockCount(Long depotId, List<Long> idList, String materialParam) {
|
||||||
|
return materialMapperEx.getListWithStockCount(depotId, idList, materialParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MaterialVo4Unit getTotalStockAndPrice(Long depotId, List<Long> idList, String materialParam) {
|
||||||
|
return materialMapperEx.getTotalStockAndPrice(depotId, idList, materialParam);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,17 @@
|
|||||||
<result column="low_decimal" jdbcType="VARCHAR" property="lowDecimal" />
|
<result column="low_decimal" jdbcType="VARCHAR" property="lowDecimal" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultMapListWithStock" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
|
||||||
|
<result column="unitName" jdbcType="VARCHAR" property="unitName" />
|
||||||
|
<result column="categoryName" jdbcType="VARCHAR" property="categoryName" />
|
||||||
|
<result column="bar_code" jdbcType="VARCHAR" property="mBarCode" />
|
||||||
|
<result column="commodity_unit" jdbcType="VARCHAR" property="commodityUnit" />
|
||||||
|
<result column="purchase_decimal" jdbcType="VARCHAR" property="purchaseDecimal" />
|
||||||
|
<result column="initialStock" jdbcType="DECIMAL" property="initialStock" />
|
||||||
|
<result column="currentStock" jdbcType="DECIMAL" property="currentStock" />
|
||||||
|
<result column="currentStockPrice" jdbcType="DECIMAL" property="currentStockPrice" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
<resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultAndUnitMap" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
|
<resultMap extends="com.jsh.erp.datasource.mappers.MaterialMapper.BaseResultMap" id="ResultAndUnitMap" type="com.jsh.erp.datasource.entities.MaterialVo4Unit">
|
||||||
<result column="unit_name" jdbcType="VARCHAR" property="unitName" />
|
<result column="unit_name" jdbcType="VARCHAR" property="unitName" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
@@ -306,4 +317,93 @@
|
|||||||
and ifnull(delete_flag,'0') !='1'
|
and ifnull(delete_flag,'0') !='1'
|
||||||
and id = #{id}
|
and id = #{id}
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<select id="getListWithStock" resultMap="ResultMapListWithStock">
|
||||||
|
select m.*, me.commodity_unit unitName, mc.name categoryName, me.bar_code,
|
||||||
|
ifnull(me.purchase_decimal,0) purchase_decimal, ifnull(sum(mis.number),0) initialStock,
|
||||||
|
ifnull(sum(mcs.current_number),0) currentStock,
|
||||||
|
sum(ifnull(me.purchase_decimal, 0) * ifnull(mcs.current_number, 0)) currentStockPrice
|
||||||
|
FROM jsh_material m
|
||||||
|
left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_material_initial_stock mis on m.id = mis.material_id and ifnull(mis.delete_flag,'0') !='1'
|
||||||
|
left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
|
||||||
|
left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||||
|
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
|
||||||
|
where 1=1
|
||||||
|
and me.default_flag=1
|
||||||
|
<if test="depotId != null">
|
||||||
|
and (mis.depot_id = #{depotId} or mcs.depot_id = #{depotId})
|
||||||
|
</if>
|
||||||
|
<if test="idList.size()>0">
|
||||||
|
and m.category_id in
|
||||||
|
<foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="materialParam != null">
|
||||||
|
<bind name="bindParam" value="'%'+materialParam+'%'"/>
|
||||||
|
and (me.bar_code like #{bindParam} or m.name like #{bindParam} or m.standard like #{bindParam} or m.model like #{bindParam})
|
||||||
|
</if>
|
||||||
|
and ifnull(m.delete_flag,'0') !='1'
|
||||||
|
group by m.id
|
||||||
|
order by m.id desc
|
||||||
|
<if test="offset != null and rows != null">
|
||||||
|
limit #{offset},#{rows}
|
||||||
|
</if>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getListWithStockCount" resultType="java.lang.Integer">
|
||||||
|
select count(tb.id) from
|
||||||
|
(select m.id from jsh_material m
|
||||||
|
left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_material_initial_stock mis on m.id = mis.material_id and ifnull(mis.delete_flag,'0') !='1'
|
||||||
|
left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
|
||||||
|
left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||||
|
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
|
||||||
|
where 1=1
|
||||||
|
and me.default_flag=1
|
||||||
|
<if test="depotId != null">
|
||||||
|
and (mis.depot_id = #{depotId} or mcs.depot_id = #{depotId})
|
||||||
|
</if>
|
||||||
|
<if test="idList.size()>0">
|
||||||
|
and m.category_id in
|
||||||
|
<foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="materialParam != null">
|
||||||
|
<bind name="bindParam" value="'%'+materialParam+'%'"/>
|
||||||
|
and (me.bar_code like #{bindParam} or m.name like #{bindParam} or m.standard like #{bindParam} or m.model like #{bindParam})
|
||||||
|
</if>
|
||||||
|
and ifnull(m.delete_flag,'0') !='1'
|
||||||
|
group by m.id) tb
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getTotalStockAndPrice" resultType="com.jsh.erp.datasource.entities.MaterialVo4Unit">
|
||||||
|
select
|
||||||
|
ifnull(sum(mcs.current_number),0) currentStock,
|
||||||
|
sum(ifnull(me.purchase_decimal,0)*ifnull(mcs.current_number,0)) currentStockPrice
|
||||||
|
from jsh_material m
|
||||||
|
left JOIN jsh_material_extend me on m.id = me.material_id and ifnull(me.delete_Flag,'0') !='1'
|
||||||
|
left join jsh_material_initial_stock mis on m.id = mis.material_id and ifnull(mis.delete_flag,'0') !='1'
|
||||||
|
left join jsh_material_current_stock mcs on m.id = mcs.material_id and ifnull(mcs.delete_flag,'0') !='1'
|
||||||
|
left JOIN jsh_unit u on m.unit_id = u.id and ifnull(u.delete_Flag,'0') !='1'
|
||||||
|
left JOIN jsh_material_category mc on m.category_id = mc.id and ifnull(mc.delete_Flag,'0') !='1'
|
||||||
|
where 1=1
|
||||||
|
and me.default_flag=1
|
||||||
|
<if test="depotId != null">
|
||||||
|
and (mis.depot_id = #{depotId} or mcs.depot_id = #{depotId})
|
||||||
|
</if>
|
||||||
|
<if test="idList.size()>0">
|
||||||
|
and m.category_id in
|
||||||
|
<foreach collection="idList" item="item" index="index" separator="," open="(" close=")">
|
||||||
|
#{item}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
|
<if test="materialParam != null">
|
||||||
|
<bind name="bindParam" value="'%'+materialParam+'%'"/>
|
||||||
|
and (me.bar_code like #{bindParam} or m.name like #{bindParam} or m.standard like #{bindParam} or m.model like #{bindParam})
|
||||||
|
</if>
|
||||||
|
and ifnull(m.delete_flag,'0') !='1'
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
Reference in New Issue
Block a user