给进销存统计报表另外增加查询接口
This commit is contained in:
parent
3533736aa8
commit
b0380732ae
@ -308,7 +308,7 @@ public class DepotItemController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 进销存统计
|
||||
* 进销存统计-即将废弃
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param depotIds
|
||||
@ -340,10 +340,10 @@ public class DepotItemController {
|
||||
String timeA = Tools.firstDayOfMonth(monthTime) + BusinessConstants.DAY_FIRST_TIME;
|
||||
String timeB = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
||||
List<Long> depotList = parseListByDepotIds(depotIds);
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getInOutStock(StringUtil.toNull(materialParam),
|
||||
categoryIdList, timeB,(currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = depotItemService.findByAllCount(StringUtil.toNull(materialParam), categoryIdList, timeB);
|
||||
int total = depotItemService.getInOutStockCount(StringUtil.toNull(materialParam), categoryIdList, timeB);
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
@ -400,7 +400,7 @@ public class DepotItemController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 进销存统计总计金额
|
||||
* 进销存统计总计金额-即将废弃
|
||||
* @param depotIds
|
||||
* @param monthTime
|
||||
* @param materialParam
|
||||
@ -424,7 +424,159 @@ public class DepotItemController {
|
||||
}
|
||||
String endTime = Tools.lastDayOfMonth(monthTime) + BusinessConstants.DAY_LAST_TIME;
|
||||
List<Long> depotList = parseListByDepotIds(depotIds);
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getInOutStock(StringUtil.toNull(materialParam),
|
||||
categoryIdList, endTime, null, null);
|
||||
BigDecimal thisAllStock = BigDecimal.ZERO;
|
||||
BigDecimal thisAllPrice = BigDecimal.ZERO;
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
Long mId = diEx.getMId();
|
||||
BigDecimal thisSum = depotItemService.getStockByParamWithDepotList(depotList,mId,null,endTime);
|
||||
thisAllStock = thisAllStock.add(thisSum);
|
||||
BigDecimal unitPrice = null;
|
||||
if(moveAvgPriceFlag) {
|
||||
unitPrice = diEx.getCurrentUnitPrice();
|
||||
} else {
|
||||
unitPrice = diEx.getPurchaseDecimal();
|
||||
}
|
||||
if(unitPrice == null) {
|
||||
unitPrice = BigDecimal.ZERO;
|
||||
}
|
||||
thisAllPrice = thisAllPrice.add(thisSum.multiply(unitPrice));
|
||||
}
|
||||
}
|
||||
map.put("totalStock", thisAllStock);
|
||||
map.put("totalCount", thisAllPrice);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (BusinessRunTimeException e) {
|
||||
res.code = e.getCode();
|
||||
res.data = e.getData().get("message");
|
||||
} catch(Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进销存统计查询
|
||||
* @param currentPage
|
||||
* @param pageSize
|
||||
* @param depotIds
|
||||
* @param beginTime
|
||||
* @param endTime
|
||||
* @param materialParam
|
||||
* @param mpList
|
||||
* @param request
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@GetMapping(value = "/getInOutStock")
|
||||
@ApiOperation(value = "进销存统计查询")
|
||||
public BaseResponseInfo getInOutStock(@RequestParam("currentPage") Integer currentPage,
|
||||
@RequestParam("pageSize") Integer pageSize,
|
||||
@RequestParam(value = "depotIds",required = false) String depotIds,
|
||||
@RequestParam(value = "categoryId", required = false) Long categoryId,
|
||||
@RequestParam("beginTime") String beginTime,
|
||||
@RequestParam("endTime") String endTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
Boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
|
||||
List<Long> categoryIdList = new ArrayList<>();
|
||||
if(categoryId != null){
|
||||
categoryIdList = materialService.getListByParentId(categoryId);
|
||||
}
|
||||
List<Long> depotList = parseListByDepotIds(depotIds);
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getInOutStock(StringUtil.toNull(materialParam),
|
||||
categoryIdList, endTime,(currentPage-1)*pageSize, pageSize);
|
||||
String[] mpArr = mpList.split(",");
|
||||
int total = depotItemService.getInOutStockCount(StringUtil.toNull(materialParam), categoryIdList, endTime);
|
||||
map.put("total", total);
|
||||
//存放数据json数组
|
||||
JSONArray dataArray = new JSONArray();
|
||||
if (null != dataList) {
|
||||
for (DepotItemVo4WithInfoEx diEx : dataList) {
|
||||
JSONObject item = new JSONObject();
|
||||
Long mId = diEx.getMId();
|
||||
item.put("barCode", diEx.getBarCode());
|
||||
item.put("materialName", diEx.getMName());
|
||||
item.put("materialModel", diEx.getMModel());
|
||||
item.put("materialStandard", diEx.getMStandard());
|
||||
//扩展信息
|
||||
String materialOther = depotItemService.getOtherInfo(mpArr, diEx);
|
||||
item.put("materialOther", materialOther);
|
||||
item.put("materialColor", diEx.getMColor());
|
||||
item.put("unitId", diEx.getUnitId());
|
||||
item.put("unitName", null!=diEx.getUnitId() ? diEx.getMaterialUnit()+"[多单位]" : diEx.getMaterialUnit());
|
||||
BigDecimal prevSum = depotItemService.getStockByParamWithDepotList(depotList,mId,null,beginTime);
|
||||
Map<String,BigDecimal> intervalMap = depotItemService.getIntervalMapByParamWithDepotList(depotList,mId,beginTime,endTime);
|
||||
BigDecimal inSum = intervalMap.get("inSum");
|
||||
BigDecimal outSum = intervalMap.get("outSum");
|
||||
BigDecimal thisSum = prevSum.add(inSum).subtract(outSum);
|
||||
item.put("prevSum", prevSum);
|
||||
item.put("inSum", inSum);
|
||||
item.put("outSum", outSum);
|
||||
item.put("thisSum", thisSum);
|
||||
//将小单位的库存换算为大单位的库存
|
||||
item.put("bigUnitStock", materialService.getBigUnitStock(thisSum, diEx.getUnitId()));
|
||||
if(moveAvgPriceFlag) {
|
||||
item.put("unitPrice", diEx.getCurrentUnitPrice());
|
||||
} else {
|
||||
item.put("unitPrice", diEx.getPurchaseDecimal());
|
||||
}
|
||||
if(moveAvgPriceFlag) {
|
||||
item.put("thisAllPrice", thisSum.multiply(diEx.getCurrentUnitPrice()));
|
||||
} else {
|
||||
item.put("thisAllPrice", thisSum.multiply(diEx.getPurchaseDecimal()));
|
||||
}
|
||||
dataArray.add(item);
|
||||
}
|
||||
}
|
||||
map.put("rows", dataArray);
|
||||
res.code = 200;
|
||||
res.data = map;
|
||||
} catch (BusinessRunTimeException e) {
|
||||
res.code = e.getCode();
|
||||
res.data = e.getData().get("message");
|
||||
} catch(Exception e){
|
||||
logger.error(e.getMessage(), e);
|
||||
res.code = 500;
|
||||
res.data = "获取数据失败";
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* 进销存统计总计金额
|
||||
* @param depotIds
|
||||
* @param endTime
|
||||
* @param materialParam
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getInOutStockCountMoney")
|
||||
@ApiOperation(value = "进销存统计总计金额")
|
||||
public BaseResponseInfo getInOutStockCountMoney(@RequestParam(value = "depotIds",required = false) String depotIds,
|
||||
@RequestParam(value = "categoryId", required = false) Long categoryId,
|
||||
@RequestParam("endTime") String endTime,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
HttpServletRequest request) throws Exception{
|
||||
BaseResponseInfo res = new BaseResponseInfo();
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
try {
|
||||
Boolean moveAvgPriceFlag = systemConfigService.getMoveAvgPriceFlag();
|
||||
List<Long> categoryIdList = new ArrayList<>();
|
||||
if(categoryId != null){
|
||||
categoryIdList = materialService.getListByParentId(categoryId);
|
||||
}
|
||||
List<Long> depotList = parseListByDepotIds(depotIds);
|
||||
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getInOutStock(StringUtil.toNull(materialParam),
|
||||
categoryIdList, endTime, null, null);
|
||||
BigDecimal thisAllStock = BigDecimal.ZERO;
|
||||
BigDecimal thisAllPrice = BigDecimal.ZERO;
|
||||
|
||||
@ -60,14 +60,14 @@ public interface DepotItemMapperEx {
|
||||
List<DepotItemVo4WithInfoEx> getBillDetailListByIds(
|
||||
@Param("idList") List<Long> idList);
|
||||
|
||||
List<DepotItemVo4WithInfoEx> findByAll(
|
||||
List<DepotItemVo4WithInfoEx> getInOutStock(
|
||||
@Param("materialParam") String materialParam,
|
||||
@Param("categoryIdList") List<Long> categoryIdList,
|
||||
@Param("endTime") String endTime,
|
||||
@Param("offset") Integer offset,
|
||||
@Param("rows") Integer rows);
|
||||
|
||||
int findByAllCount(
|
||||
int getInOutStockCount(
|
||||
@Param("materialParam") String materialParam,
|
||||
@Param("categoryIdList") List<Long> categoryIdList,
|
||||
@Param("endTime") String endTime);
|
||||
|
||||
@ -301,20 +301,20 @@ public class DepotItemService {
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<DepotItemVo4WithInfoEx> findByAll(String materialParam, List<Long> categoryIdList, String endTime, Integer offset, Integer rows)throws Exception {
|
||||
public List<DepotItemVo4WithInfoEx> getInOutStock(String materialParam, List<Long> categoryIdList, String endTime, Integer offset, Integer rows)throws Exception {
|
||||
List<DepotItemVo4WithInfoEx> list =null;
|
||||
try{
|
||||
list = depotItemMapperEx.findByAll(materialParam, categoryIdList, endTime, offset, rows);
|
||||
list = depotItemMapperEx.getInOutStock(materialParam, categoryIdList, endTime, offset, rows);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public int findByAllCount(String materialParam, List<Long> categoryIdList, String endTime)throws Exception {
|
||||
public int getInOutStockCount(String materialParam, List<Long> categoryIdList, String endTime)throws Exception {
|
||||
int result=0;
|
||||
try{
|
||||
result = depotItemMapperEx.findByAllCount(materialParam, categoryIdList, endTime);
|
||||
result = depotItemMapperEx.getInOutStockCount(materialParam, categoryIdList, endTime);
|
||||
}catch(Exception e){
|
||||
JshException.readFail(logger, e);
|
||||
}
|
||||
|
||||
@ -343,7 +343,7 @@
|
||||
order by di.header_id desc, di.id asc
|
||||
</select>
|
||||
|
||||
<select id="findByAll" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
|
||||
<select id="getInOutStock" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultByMaterial">
|
||||
select m.id MId, me.bar_code, m.name MName, m.mfrs MMfrs, m.model MModel, m.standard MStandard,
|
||||
m.other_field1 MOtherField1,m.other_field2 MOtherField2,m.other_field3 MOtherField3,
|
||||
concat_ws('', m.unit, u.basic_unit) MaterialUnit, m.color MColor, m.unit_id, u.name unit_name,
|
||||
@ -376,7 +376,7 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="findByAllCount" resultType="java.lang.Integer">
|
||||
<select id="getInOutStockCount" resultType="java.lang.Integer">
|
||||
select count(1) from (select m.id
|
||||
from jsh_material m
|
||||
left join jsh_material_extend me on me.material_id=m.id and ifnull(me.delete_Flag,'0') !='1'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user