优化入库明细和出库明细的接口

This commit is contained in:
季圣华
2022-10-13 23:08:00 +08:00
parent 97e89cb035
commit 0a9cb85654
4 changed files with 93 additions and 20 deletions

View File

@@ -92,9 +92,9 @@ public class DepotHeadController {
* @param request
* @return
*/
@GetMapping(value = "/findInDetail")
@GetMapping(value = "/findInOutDetail")
@ApiOperation(value = "入库出库明细接口")
public BaseResponseInfo findInDetail(@RequestParam("currentPage") Integer currentPage,
public BaseResponseInfo findInOutDetail(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam(value = "organId", required = false) Integer oId,
@RequestParam("number") String number,
@@ -126,9 +126,82 @@ public class DepotHeadController {
String [] organArray = depotHeadService.getOrganArray(subType, "");
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
List<DepotHeadVo4InDetail> list = depotHeadService.findInDetail(beginTime, endTime, type, creatorArray, organArray,
List<DepotHeadVo4InDetail> list = depotHeadService.findInOutDetail(beginTime, endTime, type, creatorArray, organArray,
StringUtil.toNull(materialParam), depotList, oId, StringUtil.toNull(number), remark, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findInDetailCount(beginTime, endTime, type, creatorArray, organArray,
int total = depotHeadService.findInOutDetailCount(beginTime, endTime, type, creatorArray, organArray,
StringUtil.toNull(materialParam), depotList, oId, StringUtil.toNull(number), remark);
map.put("total", total);
//存放数据json数组
if (null != list) {
for (DepotHeadVo4InDetail dhd : list) {
resList.add(dhd);
}
}
map.put("rows", resList);
res.code = 200;
res.data = map;
} catch(Exception e){
e.printStackTrace();
res.code = 500;
res.data = "获取数据失败";
}
return res;
}
/**
* 改接口准备停用
* @param currentPage
* @param pageSize
* @param oId
* @param number
* @param materialParam
* @param depotId
* @param beginTime
* @param endTime
* @param roleType
* @param type
* @param remark
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/findInDetail")
@ApiOperation(value = "入库出库明细接口")
public BaseResponseInfo findInDetail(@RequestParam("currentPage") Integer currentPage,
@RequestParam("pageSize") Integer pageSize,
@RequestParam(value = "organId", required = false) Integer oId,
@RequestParam("number") String number,
@RequestParam("materialParam") String materialParam,
@RequestParam(value = "depotId", required = false) Long depotId,
@RequestParam("beginTime") String beginTime,
@RequestParam("endTime") String endTime,
@RequestParam(value = "roleType", required = false) String roleType,
@RequestParam("type") String type,
@RequestParam("remark") String remark,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
try {
List<Long> depotList = new ArrayList<>();
if(depotId != null) {
depotList.add(depotId);
} else {
//未选择仓库时默认为当前用户有权限的仓库
JSONArray depotArr = depotService.findDepotByCurrentUser();
for(Object obj: depotArr) {
JSONObject object = JSONObject.parseObject(obj.toString());
depotList.add(object.getLong("id"));
}
}
List<DepotHeadVo4InDetail> resList = new ArrayList<DepotHeadVo4InDetail>();
String [] creatorArray = depotHeadService.getCreatorArray(roleType);
String subType = "出库".equals(type)? "销售" : "";
String [] organArray = depotHeadService.getOrganArray(subType, "");
beginTime = Tools.parseDayToTime(beginTime, BusinessConstants.DAY_FIRST_TIME);
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
List<DepotHeadVo4InDetail> list = depotHeadService.findInOutDetail(beginTime, endTime, type, creatorArray, organArray,
StringUtil.toNull(materialParam), depotList, oId, StringUtil.toNull(number), remark, (currentPage-1)*pageSize, pageSize);
int total = depotHeadService.findInOutDetailCount(beginTime, endTime, type, creatorArray, organArray,
StringUtil.toNull(materialParam), depotList, oId, StringUtil.toNull(number), remark);
map.put("total", total);
//存放数据json数组

View File

@@ -61,7 +61,7 @@ public interface DepotHeadMapperEx {
String findMaterialsListByHeaderId(
@Param("id") Long id);
List<DepotHeadVo4InDetail> findInDetail(
List<DepotHeadVo4InDetail> findInOutDetail(
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("type") String type,
@@ -75,7 +75,7 @@ public interface DepotHeadMapperEx {
@Param("offset") Integer offset,
@Param("rows") Integer rows);
int findInDetailCount(
int findInOutDetailCount(
@Param("beginTime") String beginTime,
@Param("endTime") String endTime,
@Param("type") String type,

View File

@@ -486,24 +486,24 @@ public class DepotHeadService {
return result;
}
public List<DepotHeadVo4InDetail> findInDetail(String beginTime, String endTime, String type, String [] creatorArray,
public List<DepotHeadVo4InDetail> findInOutDetail(String beginTime, String endTime, String type, String [] creatorArray,
String [] organArray, String materialParam, List<Long> depotList, Integer oId, String number,
String remark, Integer offset, Integer rows) throws Exception{
List<DepotHeadVo4InDetail> list = null;
try{
list =depotHeadMapperEx.findInDetail(beginTime, endTime, type, creatorArray, organArray, materialParam, depotList, oId, number, remark, offset, rows);
list =depotHeadMapperEx.findInOutDetail(beginTime, endTime, type, creatorArray, organArray, materialParam, depotList, oId, number, remark, offset, rows);
}catch(Exception e){
JshException.readFail(logger, e);
}
return list;
}
public int findInDetailCount(String beginTime, String endTime, String type, String [] creatorArray,
public int findInOutDetailCount(String beginTime, String endTime, String type, String [] creatorArray,
String [] organArray, String materialParam, List<Long> depotList, Integer oId, String number,
String remark) throws Exception{
int result = 0;
try{
result =depotHeadMapperEx.findInDetailCount(beginTime, endTime, type, creatorArray, organArray, materialParam, depotList, oId, number, remark);
result =depotHeadMapperEx.findInOutDetailCount(beginTime, endTime, type, creatorArray, organArray, materialParam, depotList, oId, number, remark);
}catch(Exception e){
JshException.readFail(logger, e);
}

View File

@@ -239,7 +239,7 @@
and ifnull(jsh_depot_item.delete_flag,'0') !='1'
</select>
<select id="findInDetail" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
<select id="findInOutDetail" parameterType="com.jsh.erp.datasource.entities.DepotItemExample" resultMap="ResultWithInfoExMap">
select dh.number,me.bar_code, m.`name` MName,m.model,m.standard,di.unit_price,di.material_unit as mUnit,
di.oper_number,di.all_price, ifnull(di.tax_rate,0) tax_rate, ifnull(di.tax_money,0) tax_money, ifnull(di.tax_last_money,0) tax_last_money,
s.supplier SName,d.dName DName, date_format(dh.oper_time, '%Y-%m-%d') OperTime, concat(dh.sub_type,dh.type) as NewType,
@@ -271,11 +271,11 @@
)
</if>
<if test="organArray != null and organArray !=''">
and dh.organ_id in (
and (dh.organ_id in (
<foreach collection="organArray" item="organId" separator=",">
#{organId}
</foreach>
)
) or dh.sub_type='采购退货' or dh.sub_type='零售')
</if>
<if test="number != null and number !=''">
<bind name="bindNumber" value="'%'+number+'%'"/>
@@ -297,7 +297,7 @@
</if>
</select>
<select id="findInDetailCount" resultType="java.lang.Integer">
<select id="findInOutDetailCount" resultType="java.lang.Integer">
select count(1)
from jsh_depot_head dh
left join jsh_depot_item di on di.header_id=dh.id and ifnull(di.delete_flag,'0') !='1'
@@ -326,11 +326,11 @@
)
</if>
<if test="organArray != null and organArray !=''">
and dh.organ_id in (
and (dh.organ_id in (
<foreach collection="organArray" item="organId" separator=",">
#{organId}
</foreach>
)
) or dh.sub_type='采购退货' or dh.sub_type='零售')
</if>
<if test="number != null and number !=''">
<bind name="bindNumber" value="'%'+number+'%'"/>
@@ -372,11 +372,11 @@
)
</if>
<if test="organArray != null and organArray !=''">
and dh.organ_id in (
and (dh.organ_id in (
<foreach collection="organArray" item="organId" separator=",">
#{organId}
</foreach>
)
) or dh.sub_type='采购退货' or dh.sub_type='零售')
</if>
<if test="depotList.size()>0">
<if test="type == '入库'">
@@ -429,11 +429,11 @@
)
</if>
<if test="organArray != null and organArray !=''">
and dh.organ_id in (
and (dh.organ_id in (
<foreach collection="organArray" item="organId" separator=",">
#{organId}
</foreach>
)
) or dh.sub_type='采购退货' or dh.sub_type='零售')
</if>
<if test="depotList.size()>0">
<if test="type == '入库'">