给采购销售统计和出入库汇总接口增加数据角色类型参数

This commit is contained in:
季圣华 2022-08-08 23:55:56 +08:00
parent 9a496ffa87
commit f89a9c006a
8 changed files with 97 additions and 43 deletions

View File

@ -51,12 +51,6 @@ public class DepotHeadController {
@Resource
private DepotHeadService depotHeadService;
@Resource
private AccountHeadService accountHeadService;
@Resource
private SupplierService supplierService;
@Resource
private DepotService depotService;
@ -175,6 +169,7 @@ public class DepotHeadController {
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam("type") String type,
@RequestParam(value = "roleType", required = false) String roleType,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
@ -193,8 +188,9 @@ public class DepotHeadController {
beginTime = Tools.parseDayToTime(beginTime,BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
List<DepotHeadVo4InOutMCount> list = depotHeadService.findInOutMaterialCount(beginTime, endTime, type, StringUtil.toNull(materialParam),
depotList, oId, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, StringUtil.toNull(materialParam), depotList, oId);
depotList, oId, roleType, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findInOutMaterialCountTotal(beginTime, endTime, type, StringUtil.toNull(materialParam),
depotList, oId, roleType);
map.put("total", total);
map.put("rows", list);
res.code = 200;

View File

@ -9,6 +9,7 @@ import com.jsh.erp.datasource.vo.DepotItemStockWarningCount;
import com.jsh.erp.datasource.vo.DepotItemVoBatchNumberList;
import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.depot.DepotService;
import com.jsh.erp.service.depotHead.DepotHeadService;
import com.jsh.erp.service.materialExtend.MaterialExtendService;
import com.jsh.erp.service.depotItem.DepotItemService;
import com.jsh.erp.service.material.MaterialService;
@ -42,24 +43,21 @@ import static com.jsh.erp.utils.Tools.getCenternTime;
public class DepotItemController {
private Logger logger = LoggerFactory.getLogger(DepotItemController.class);
@Resource
private DepotHeadService depotHeadService;
@Resource
private DepotItemService depotItemService;
@Resource
private MaterialService materialService;
@Resource
private MaterialExtendService materialExtendService;
@Resource
private UnitService unitService;
@Resource
private DepotService depotService;
@Resource
private RedisService redisService;
/**
* 根据仓库和商品查询单据列表
* @param mId
@ -423,26 +421,29 @@ public class DepotItemController {
@RequestParam("endTime") String endTime,
@RequestParam("materialParam") String materialParam,
@RequestParam("mpList") String mpList,
@RequestParam(value = "roleType", required = false) String roleType,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
try {
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getListWithBugOrSale(StringUtil.toNull(materialParam),
"buy", beginTime, endTime, (currentPage-1)*pageSize, pageSize);
"buy", beginTime, endTime, creatorArray, (currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(",");
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam), "buy", beginTime, endTime);
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam),
"buy", beginTime, endTime, creatorArray);
map.put("total", total);
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
BigDecimal InSum = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, "number");
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, "number");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, "price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, "price");
BigDecimal InSum = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, creatorArray, "number");
BigDecimal OutSum = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, creatorArray, "number");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "采购", diEx.getMId(), beginTime, endTime, creatorArray, "price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "采购退货", diEx.getMId(), beginTime, endTime, creatorArray, "price");
BigDecimal InOutSumPrice = InSumPrice.subtract(OutSumPrice);
item.put("barCode", diEx.getBarCode());
item.put("materialName", diEx.getMName());
@ -492,30 +493,33 @@ public class DepotItemController {
@RequestParam("endTime") String endTime,
@RequestParam("materialParam") String materialParam,
@RequestParam("mpList") String mpList,
@RequestParam(value = "roleType", required = false) String roleType,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
try {
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
List<DepotItemVo4WithInfoEx> dataList = depotItemService.getListWithBugOrSale(StringUtil.toNull(materialParam),
"sale", beginTime, endTime,(currentPage-1)*pageSize, pageSize);
"sale", beginTime, endTime, creatorArray, (currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(",");
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam), "sale", beginTime, endTime);
int total = depotItemService.getListWithBugOrSaleCount(StringUtil.toNull(materialParam),
"sale", beginTime, endTime, creatorArray);
map.put("total", total);
//存放数据json数组
JSONArray dataArray = new JSONArray();
if (null != dataList) {
for (DepotItemVo4WithInfoEx diEx : dataList) {
JSONObject item = new JSONObject();
BigDecimal OutSumRetail = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime,"number");
BigDecimal OutSum = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime,"number");
BigDecimal InSumRetail = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime,"number");
BigDecimal InSum = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime,"number");
BigDecimal OutSumRetailPrice = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime,"price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime,"price");
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime,"price");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime,"price");
BigDecimal OutSumRetail = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime, creatorArray,"number");
BigDecimal OutSum = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime, creatorArray,"number");
BigDecimal InSumRetail = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime, creatorArray,"number");
BigDecimal InSum = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime, creatorArray,"number");
BigDecimal OutSumRetailPrice = depotItemService.buyOrSale("出库", "零售", diEx.getMId(), beginTime, endTime, creatorArray,"price");
BigDecimal OutSumPrice = depotItemService.buyOrSale("出库", "销售", diEx.getMId(), beginTime, endTime, creatorArray,"price");
BigDecimal InSumRetailPrice = depotItemService.buyOrSale("入库", "零售退货", diEx.getMId(), beginTime, endTime, creatorArray,"price");
BigDecimal InSumPrice = depotItemService.buyOrSale("入库", "销售退货", diEx.getMId(), beginTime, endTime, creatorArray,"price");
BigDecimal OutInSumPrice = (OutSumRetailPrice.add(OutSumPrice)).subtract(InSumRetailPrice.add(InSumPrice));
item.put("barCode", diEx.getBarCode());
item.put("materialName", diEx.getMName());

View File

@ -90,6 +90,7 @@ public interface DepotHeadMapperEx {
@Param("materialParam") String materialParam,
@Param("depotList") List<Long> depotList,
@Param("oId") Integer oId,
@Param("creatorArray") String[] creatorArray,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
@ -99,7 +100,8 @@ public interface DepotHeadMapperEx {
@Param("type") String type,
@Param("materialParam") String materialParam,
@Param("depotList") List<Long> depotList,
@Param("oId") Integer oId);
@Param("oId") Integer oId,
@Param("creatorArray") String[] creatorArray);
List<DepotHeadVo4InDetail> findAllocationDetail(
@Param("beginTime") String beginTime,

View File

@ -59,6 +59,7 @@ public interface DepotItemMapperEx {
@Param("billType") String billType,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,
@Param("offset") Integer offset,
@Param("rows") Integer rows);
@ -66,7 +67,8 @@ public interface DepotItemMapperEx {
@Param("materialParam") String materialParam,
@Param("billType") String billType,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime);
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray);
BigDecimal buyOrSaleNumber(
@Param("type") String type,
@ -74,6 +76,7 @@ public interface DepotItemMapperEx {
@Param("MId") Long MId,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,
@Param("sumType") String sumType);
BigDecimal buyOrSalePrice(
@ -82,6 +85,7 @@ public interface DepotItemMapperEx {
@Param("MId") Long MId,
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("creatorArray") String[] creatorArray,
@Param("sumType") String sumType);
BigDecimal inOrOutPrice(

View File

@ -472,20 +472,23 @@ public class DepotHeadService {
}
public List<DepotHeadVo4InOutMCount> findInOutMaterialCount(String beginTime, String endTime, String type, String materialParam,
List<Long> depotList, Integer oId, Integer offset, Integer rows)throws Exception {
List<Long> depotList, Integer oId, String roleType, Integer offset, Integer rows)throws Exception {
List<DepotHeadVo4InOutMCount> list = null;
try{
list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, materialParam, depotList, oId, offset, rows);
String [] creatorArray = getCreatorArray(roleType);
list =depotHeadMapperEx.findInOutMaterialCount(beginTime, endTime, type, materialParam, depotList, oId, creatorArray, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, String materialParam, List<Long> depotList, Integer oId)throws Exception {
public int findInOutMaterialCountTotal(String beginTime, String endTime, String type, String materialParam,
List<Long> depotList, Integer oId, String roleType)throws Exception {
int result = 0;
try{
result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotList, oId);
String [] creatorArray = getCreatorArray(roleType);
result =depotHeadMapperEx.findInOutMaterialCountTotal(beginTime, endTime, type, materialParam, depotList, oId, creatorArray);
}catch(Exception e){
JshException.readFail(logger, e);
}

View File

@ -305,33 +305,36 @@ public class DepotItemService {
return result;
}
public List<DepotItemVo4WithInfoEx> getListWithBugOrSale(String materialParam, String billType, String beginTime, String endTime, Integer offset, Integer rows)throws Exception {
public List<DepotItemVo4WithInfoEx> getListWithBugOrSale(String materialParam, String billType,
String beginTime, String endTime, String[] creatorArray, Integer offset, Integer rows)throws Exception {
List<DepotItemVo4WithInfoEx> list =null;
try{
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, offset, rows);
list = depotItemMapperEx.getListWithBugOrSale(materialParam, billType, beginTime, endTime, creatorArray, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int getListWithBugOrSaleCount(String materialParam, String billType, String beginTime, String endTime)throws Exception {
public int getListWithBugOrSaleCount(String materialParam, String billType,
String beginTime, String endTime, String[] creatorArray)throws Exception {
int result=0;
try{
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime);
result = depotItemMapperEx.getListWithBugOrSaleCount(materialParam, billType, beginTime, endTime, creatorArray);
}catch(Exception e){
JshException.readFail(logger, e);
}
return result;
}
public BigDecimal buyOrSale(String type, String subType, Long MId, String beginTime, String endTime, String sumType) throws Exception{
public BigDecimal buyOrSale(String type, String subType, Long MId, String beginTime, String endTime,
String[] creatorArray, String sumType) throws Exception{
BigDecimal result= BigDecimal.ZERO;
try{
if (SUM_TYPE.equals(sumType)) {
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, beginTime, endTime, sumType);
result= depotItemMapperEx.buyOrSaleNumber(type, subType, MId, beginTime, endTime, creatorArray, sumType);
} else {
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, beginTime, endTime, sumType);
result= depotItemMapperEx.buyOrSalePrice(type, subType, MId, beginTime, endTime, creatorArray, sumType);
}
}catch(Exception e){
JshException.readFail(logger, e);

View File

@ -331,6 +331,13 @@
<if test="oId != null">
and dh.organ_id = #{oId}
</if>
<if test="creatorArray != null">
and dh.creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
<if test="depotList.size()>0">
<if test="type == '入库'">
and ((
@ -374,6 +381,13 @@
<if test="oId != null">
and dh.organ_id = #{oId}
</if>
<if test="creatorArray != null">
and dh.creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
<if test="depotList.size()>0">
<if test="type == '入库'">
and ((

View File

@ -315,6 +315,13 @@
<if test="endTime != null">
and dh.oper_time &lt;= #{endTime}
</if>
<if test="creatorArray != null">
and dh.creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
and ifnull(m.delete_flag,'0') !='1'
group by m.id
order by m.id desc
@ -346,6 +353,13 @@
<if test="endTime != null">
and dh.oper_time &lt;= #{endTime}
</if>
<if test="creatorArray != null">
and dh.creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
and ifnull(di.delete_flag,'0') !='1'
group by m.id) cc
</select>
@ -357,6 +371,13 @@
and di.material_id =#{MId}
and dh.oper_time &gt;= #{beginTime}
and dh.oper_time &lt;= #{endTime}
<if test="creatorArray != null">
and dh.creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
</select>
@ -368,6 +389,13 @@
and di.material_id =#{MId}
and dh.oper_time &gt;= #{beginTime}
and dh.oper_time &lt;= #{endTime}
<if test="creatorArray != null">
and dh.creator in (
<foreach collection="creatorArray" item="creator" separator=",">
#{creator}
</foreach>
)
</if>
and ifnull(dh.delete_flag,'0') !='1'
and ifnull(di.delete_flag,'0') !='1'
</select>