Merge remote-tracking branch 'origin/master'

This commit is contained in:
zhangzhiqiang
2023-10-11 19:50:59 +08:00
8 changed files with 376 additions and 1 deletions

View File

@@ -34,5 +34,11 @@ public interface StIvtStructivtDailyMapper extends BaseMapper<StIvtStructivtDail
* @return /
*/
List<JSONObject> getIoNum(@Param("query") Map json);
/**
* 收发存查询
* @return /
*/
List<JSONObject> getPhyIvt(@Param("query") Map json);
}

View File

@@ -83,4 +83,42 @@
</select>
<select id="getPhyIvt" resultType="com.alibaba.fastjson.JSONObject">
SELECT
mater.material_id,
mater.material_code,
mater.material_name,
mater.material_spec,
MAX(unit.unit_name) AS qty_unit_name,
SUM(da.in_qty) AS in_qty,
SUM(da.out_qty) AS out_qty,
SUM(da.canuse_qty) AS canuse_qty
FROM
st_ivt_structivt_daily da
LEFT JOIN md_me_materialbase mater ON da.material_id = mater.material_id
LEFT JOIN md_pb_measureunit unit ON unit.measure_unit_id = da.qty_unit_id
<where>
1 = 1
<if test="query.stor_id != null and query.stor_id != ''">
and da.stor_id = #{query.stor_id}
</if>
<if test="query.begin_time != null and query.begin_time != ''">
and da.create_time >= #{query.begin_time}
</if>
<if test="query.end_time != null and query.end_time != ''">
and #{query.end_time} >= da.create_time
</if>
<if test="query.material_code != null and query.material_code != ''">
and (mater.material_code LIKE '%${query.material_code}%' or
mater.material_name LIKE '%${query.material_code}%' or
mater.material_spec LIKE '%${query.material_code}%')
</if>
group by mater.material_id
</where>
</select>
</mapper>

View File

@@ -0,0 +1,38 @@
package org.nl.wms.stata_manage.rest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.stata_manage.service.PhyivtService;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Map;
/**
* @author Liuxy
* @date 2022-06-28
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "收发存查询")
@RequestMapping("/api/phyivt")
@Slf4j
public class PhyivtController {
private final PhyivtService phyivtService;
@GetMapping
@ApiOperation("库存查询")
public ResponseEntity<Object> query(@RequestParam Map whereJson, Pageable page) {
return new ResponseEntity<>(phyivtService.queryAll(whereJson, page), HttpStatus.OK);
}
}

View File

@@ -0,0 +1,24 @@
package org.nl.wms.stata_manage.service;
import org.springframework.data.domain.Pageable;
import java.util.Map;
/**
* @author Liuxy
* @description 服务接口
* @date 2022-06-28
**/
public interface PhyivtService {
/**
* 查询数据分页
*
* @param whereJson 条件
* @param page 分页参数
* @return Map<String, Object>
*/
Map<String, Object> queryAll(Map whereJson, Pageable page);
}

View File

@@ -0,0 +1,69 @@
package org.nl.wms.stata_manage.service.impl;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.utils.PageUtil;
import org.nl.wms.masterdata_manage.storage.service.dailyStructivt.dao.StIvtStructivtDaily;
import org.nl.wms.masterdata_manage.storage.service.dailyStructivt.dao.mapper.StIvtStructivtDailyMapper;
import org.nl.wms.stata_manage.service.PhyivtService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author Liuxy
* @description 服务实现
* @date 2022-06-28
**/
@Service
@RequiredArgsConstructor
@Slf4j
public class PhyivtServiceImpl implements PhyivtService {
@Autowired
private StIvtStructivtDailyMapper stIvtStructivtDailyMapper;
@Override
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
whereJson.put("begin_time", MapUtil.getStr(whereJson, "begin_time").substring(0,10));
whereJson.put("end_time", MapUtil.getStr(whereJson, "end_time").substring(0,10));
List<JSONObject> phyIvtList = stIvtStructivtDailyMapper.getPhyIvt(whereJson);
// 计算期初数
List<StIvtStructivtDaily> beginList = stIvtStructivtDailyMapper.selectList(
new QueryWrapper<StIvtStructivtDaily>().lambda()
.eq(StIvtStructivtDaily::getCreate_time, MapUtil.getStr(whereJson, "begin_time").substring(0, 10))
);
for(JSONObject json : phyIvtList) {
List<StIvtStructivtDaily> dao = beginList.stream()
.filter(row -> row.getMaterial_id().equals(json.getString("material_id")))
.collect(Collectors.toList());
json.put("begin_qty", ObjectUtil.isNotEmpty(dao) ? dao.get(0).getCanuse_qty() : 0);
}
// 处理分页
Map<String, Object> json = PageUtil.toPage(
PageUtil.toPage(page.getPageNumber(), page.getPageSize(), phyIvtList),
phyIvtList.size()
);
return json;
}
}