7a610143 康伟

kangwei : 修改计划采购的统计方法以及查询方法

1 个父辈 47cbed7d
......@@ -22,10 +22,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.erp.vo.PurchasePlanSearchVO;
import com.skua.modules.erp.vo.PurchasePlanStatisticsVO;
import com.skua.modules.erp.vo.PurchasePlanVO;
import com.skua.modules.guest.util.DateUtil;
import com.skua.modules.supplies.service.IEquipmentSparepartTypeService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
......@@ -55,6 +58,8 @@ import io.swagger.annotations.ApiOperation;
public class PurchasePlanController {
@Autowired
private IPurchasePlanService purchasePlanService;
@Autowired
private IEquipmentSparepartTypeService equipmentSparepartTypeService;
@AutoLog(value = "erp采购计划表-分页列表查询")
@ApiOperation(value="erp采购计划表-分页列表查询", notes="erp采购计划表-分页列表查询")
......@@ -66,22 +71,20 @@ public class PurchasePlanController {
Result<IPage<PurchasePlan>> result = new Result<IPage<PurchasePlan>>();
QueryWrapper<PurchasePlan> queryWrapper = QueryGenerator.initQueryWrapper(purchasePlan, req.getParameterMap());
Page<PurchasePlan> page = new Page<PurchasePlan>(pageNo, pageSize);
/*if(purchasePlanVO.getDepartId() != null ){
queryWrapper.eq("depart_id", purchasePlanVO.getDepartId());
if(StringUtils.isNotEmpty( purchasePlan.getDepartId() ) ){
queryWrapper.eq("depart_id", purchasePlan.getDepartId());
}
if(purchasePlanVO.getStatus() != null ){
queryWrapper.eq("status", purchasePlanVO.getStatus());
if(StringUtils.isNotEmpty( purchasePlan.getStatus() ) ){
queryWrapper.eq("status", purchasePlan.getStatus());
}
if(purchasePlanVO.getApplyYear() != null ){
queryWrapper.eq("apply_year", purchasePlanVO.getApplyYear());
if( StringUtils.isNotEmpty( purchasePlan.getApplyYear() ) ){
queryWrapper.eq("apply_year", purchasePlan.getApplyYear());
}
if(purchasePlanVO.getApplyYear() != null ){
queryWrapper.eq("apply_year", purchasePlanVO.getApplyYear());
if(StringUtils.isNotEmpty( purchasePlan.getApplyUser()) ){
queryWrapper.like("apply_user", purchasePlan.getApplyUser());
}
if(purchasePlanVO.getApplyUser() != null ){
queryWrapper.like("apply_user", purchasePlanVO.getApplyUser());
}*/
queryWrapper.orderByDesc("create_time");
IPage<PurchasePlan> pageList = purchasePlanService.page(page, queryWrapper);
......@@ -102,24 +105,28 @@ public class PurchasePlanController {
QueryWrapper<PurchasePlan> queryWrapper = QueryGenerator.initQueryWrapper(purchasePlan, req.getParameterMap());
Page<PurchasePlan> page = new Page<PurchasePlan>(pageNo, pageSize);
/* queryWrapper.in("depart_id", BaseContextHandler.getDeparts().split(","));
if(purchasePlan.getStatus() != null ){
queryWrapper.eq("status", purchasePlan.getStatus());
if(StringUtils.isNotEmpty( purchasePlan.getDepartId() ) ){
queryWrapper.eq("depart_id", purchasePlan.getDepartId());
}else{
//如果为管理员,则跳过权限
if (!"1".equals(BaseContextHandler.get("userType"))) {
queryWrapper.in("depart_id", BaseContextHandler.getDeparts().split(","));
}
}
if(purchasePlan.getApplyYear() != null ){
queryWrapper.eq("apply_year", purchasePlan.getApplyYear());
if(StringUtils.isNotEmpty( purchasePlan.getStatus() ) ){
queryWrapper.eq("status", purchasePlan.getStatus());
}else{
queryWrapper.gt("status" , "0");// >0
queryWrapper.ne("status" , "2"); // 不等于2
}
if(purchasePlan.getApplyYear() != null ){
if( StringUtils.isNotEmpty( purchasePlan.getApplyYear()) ){
queryWrapper.eq("apply_year", purchasePlan.getApplyYear());
}
if(purchasePlan.getApplyUser() != null ){
if( StringUtils.isNotEmpty( purchasePlan.getApplyUser() ) ){
queryWrapper.like("apply_user", purchasePlan.getApplyUser());
}*/
queryWrapper.in("depart_id", BaseContextHandler.getDeparts().split(","));
queryWrapper.gt("status" , "0");// >0
queryWrapper.ne("status" , "2"); // 不等于2
}
queryWrapper.orderByDesc("create_time");
IPage<PurchasePlan> pageList = purchasePlanService.page(page, queryWrapper);
result.setSuccess(true);
......@@ -292,6 +299,20 @@ public class PurchasePlanController {
Page<PurchasePlanItem> page = new Page<PurchasePlanItem>(pageNo, pageSize);
//purchasePlanSearchVO.setDepats();
purchasePlanSearchVO.setDeparts(BaseContextHandler.getDeparts());
Set<String> sparepartTypeSet = new HashSet<>();
String sparepartTypeStr = "";
if (StringUtils.isNotEmpty(purchasePlanSearchVO.getSparepartType())) {
// 查询子集
sparepartTypeSet = equipmentSparepartTypeService.getAllChildrenSparepartTypeIds( purchasePlanSearchVO.getSparepartType() );
if(sparepartTypeSet.size() > 0 ){
// 使用String.join()方法转换Set为字符串,以逗号分隔
sparepartTypeStr = String.join(",", sparepartTypeSet);
}
purchasePlanSearchVO.setSparepartType( sparepartTypeStr );
}
IPage<PurchasePlanItem> pageList = purchasePlanService.statisticsPage(page,purchasePlanSearchVO);
result.setSuccess(true);
result.setResult(pageList);
......@@ -301,15 +322,15 @@ public class PurchasePlanController {
@AutoLog(value = "erp采购计划表-统计详情")
@ApiOperation(value="erp采购计划表-统计详情", notes="erp采购计划表-统计详情")
@GetMapping(value = "/statisticsDetail")
public Result<IPage<PurchasePlanItem>> statisticsDetail(PurchasePlanSearchVO purchasePlanSearchVO,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<PurchasePlanItem>> result = new Result<IPage<PurchasePlanItem>>();
public Result<IPage<PurchasePlanStatisticsVO>> statisticsDetail(PurchasePlanSearchVO purchasePlanSearchVO,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Result<IPage<PurchasePlanStatisticsVO>> result = new Result<IPage<PurchasePlanStatisticsVO>>();
Page<PurchasePlanItem> page = new Page<PurchasePlanItem>(pageNo, pageSize);
purchasePlanSearchVO.setDeparts(BaseContextHandler.getDeparts());
IPage<PurchasePlanItem> pageList = purchasePlanService.statisticsPageBySparepartId(page,purchasePlanSearchVO);
Page<PurchasePlanStatisticsVO> page = new Page<PurchasePlanStatisticsVO>(pageNo, pageSize);
//purchasePlanSearchVO.setDeparts(BaseContextHandler.getDeparts());
IPage<PurchasePlanStatisticsVO> pageList = purchasePlanService.statisticsPageBySparepartId(page,purchasePlanSearchVO);
result.setSuccess(true);
result.setResult(pageList);
return result;
......
......@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.skua.modules.erp.entity.PurchaseMaterial;
import com.skua.modules.erp.entity.PurchasePlanItem;
import com.skua.modules.erp.vo.PurchasePlanSearchVO;
import com.skua.modules.erp.vo.PurchasePlanStatisticsVO;
import org.apache.ibatis.annotations.Param;
import com.skua.modules.erp.entity.PurchasePlan;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -30,6 +31,6 @@ public interface PurchasePlanMapper extends BaseMapper<PurchasePlan> {
* @param page
* @return
*/
IPage<PurchasePlanItem> statisticsPageBySparepartId(Page<PurchasePlanItem> page, @Param("ev")PurchasePlanSearchVO purchasePlanSearchVO);
IPage<PurchasePlanStatisticsVO> statisticsPageBySparepartId(Page<PurchasePlanStatisticsVO> page, @Param("ev")PurchasePlanSearchVO purchasePlanSearchVO);
}
......
......@@ -3,13 +3,13 @@
<mapper namespace="com.skua.modules.erp.mapper.PurchasePlanMapper">
<!-- 统计查询-->
<select id="statisticsPage" resultType="com.skua.modules.erp.entity.PurchasePlanItem">
select ss.id, ss.sparepart_name,ss.sparepart_type, st.item_text as 'sparepart_type_name' ,ss.sparepart_code, ss.specification,ss.measuring_unit, aaa.* from (
select ss.id, ss.sparepart_name,ss.sparepart_type, st.item_textstatisticsPage as 'sparepart_type_name' ,ss.sparepart_code, ss.specification,ss.measuring_unit, aaa.* from (
select pi.sparepart_id,sum(pi.purchase_num ) as 'purchase_num' , sum(pi.total_price) 'total_price'
from erp_purchase_plan_item pi ,erp_purchase_plan pp
where
pp.id = pi.plan_id
<if test="ev.sparepartType != null and ev.sparepartType != '' ">
and pi.sparepart_type = #{ev.sparepartType}
and pi.sparepart_type in ( ${ev.sparepartType})
</if>
<if test="ev.sparepartCode != null and ev.sparepartCode != '' ">
AND pi.sparepart_code like concat('%', #{ev.sparepartCode}, '%')
......@@ -21,7 +21,7 @@
and pp.apply_year = #{ev.applyYear}
</if>
<if test="ev.departId != null and ev.departId!= ''">
and pp.depart_id = #{ev.departId}
and pp.depart_id in ( ${ev.departId} )
</if>
<if test="ev.startTime != null and ev.startTime!= ''">
and pp.apply_time &gt;= #{ev.startTime}
......@@ -36,33 +36,32 @@
</select>
<select id="statisticsPageBySparepartId" resultType="com.skua.modules.erp.entity.PurchasePlanItem">
select st.item_text as 'sparepart_type_name' , d.depart_name , aaa.*
from (
select pi.* ,pp.depart_id
from erp_purchase_plan_item pi ,erp_purchase_plan pp
where pp.id = pi.plan_id and pi.sparepart_id=#{ev.sparepartId}
<if test="ev.sparepartType != null and ev.sparepartType != '' ">
and pi.sparepart_type = #{ev.sparepartType}
</if> <if test="ev.sparepartName != null and ev.sparepartName != '' ">
AND pi.sparepart_name like concat('%', #{ev.sparepartName}, '%')
</if>
<if test="ev.applyYear != null and ev.applyYear != '' ">
and pp.apply_year = #{ev.applyYear}
</if>
<if test="ev.departId != null and ev.departId!= ''">
and pp.depart_id = #{ev.departId}
</if>
<if test="ev.startTime != null and ev.startTime!= ''">
and pp.apply_time &gt;= #{ev.startTime}
</if>
<if test="ev.endTime != null and ev.endTime != ''">
and pp.apply_time &lt;= #{ev.endTime}
</if>
<select id="statisticsPageBySparepartId" resultType="com.skua.modules.erp.vo.PurchasePlanStatisticsVO">
select u.realname 'apply_user_name', aaa.* from (
select pi.purchase_num ,pi.measuring_unit,pi.sparepart_name, pi.unit_price , pi.total_price , pp.*
from erp_purchase_plan_item pi ,erp_purchase_plan pp
where pp.id = pi.plan_id and pi.sparepart_id=#{ev.sparepartId}
<if test="ev.sparepartType != null and ev.sparepartType != '' ">
and pi.sparepart_type = #{ev.sparepartType}
</if> <if test="ev.sparepartName != null and ev.sparepartName != '' ">
AND pi.sparepart_name like concat('%', #{ev.sparepartName}, '%')
</if>
<if test="ev.applyYear != null and ev.applyYear != '' ">
and pp.apply_year = #{ev.applyYear}
</if>
<if test="ev.departId != null and ev.departId!= ''">
and pp.depart_id = #{ev.departId}
</if>
<if test="ev.startTime != null and ev.startTime!= ''">
and pp.apply_time &gt;= #{ev.startTime}
</if>
<if test="ev.endTime != null and ev.endTime != ''">
and pp.apply_time &lt;= #{ev.endTime}
</if>
)aaa
left join equipment_sparepart_type st on st.id = aaa.sparepart_type
left join sys_depart d on d.id = aaa.depart_id
left join sys_user u on u.id = aaa.apply_user
</select>
<!-- and pp.depart_id in (#{ev.departs})-->
</mapper>
\ No newline at end of file
......
......@@ -6,6 +6,7 @@ import com.skua.modules.erp.entity.PurchasePlan;
import com.baomidou.mybatisplus.extension.service.IService;
import com.skua.modules.erp.entity.PurchasePlanItem;
import com.skua.modules.erp.vo.PurchasePlanSearchVO;
import com.skua.modules.erp.vo.PurchasePlanStatisticsVO;
import com.skua.modules.erp.vo.PurchasePlanVO;
import java.util.List;
......@@ -69,6 +70,6 @@ public interface IPurchasePlanService extends IService<PurchasePlan> {
* @param page
* @return
*/
IPage<PurchasePlanItem> statisticsPageBySparepartId(Page<PurchasePlanItem> page, PurchasePlanSearchVO purchasePlanSearchVO);
IPage<PurchasePlanStatisticsVO> statisticsPageBySparepartId(Page<PurchasePlanStatisticsVO> page, PurchasePlanSearchVO purchasePlanSearchVO);
}
......
......@@ -12,6 +12,7 @@ import com.skua.modules.erp.mapper.PurchasePlanItemMapper;
import com.skua.modules.erp.mapper.PurchasePlanMapper;
import com.skua.modules.erp.service.IPurchasePlanService;
import com.skua.modules.erp.vo.PurchasePlanSearchVO;
import com.skua.modules.erp.vo.PurchasePlanStatisticsVO;
import com.skua.modules.erp.vo.PurchasePlanVO;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
......@@ -167,7 +168,7 @@ public class PurchasePlanServiceImpl extends ServiceImpl<PurchasePlanMapper, Pur
* @param page
* @return
*/
public IPage<PurchasePlanItem> statisticsPageBySparepartId(Page<PurchasePlanItem> page, PurchasePlanSearchVO purchasePlanSearchVO){
public IPage<PurchasePlanStatisticsVO> statisticsPageBySparepartId(Page<PurchasePlanStatisticsVO> page, PurchasePlanSearchVO purchasePlanSearchVO){
return this.baseMapper.statisticsPageBySparepartId(page,purchasePlanSearchVO);
}
}
......
package com.skua.modules.erp.vo;
import com.skua.modules.erp.entity.PurchasePlan;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecgframework.poi.excel.annotation.Excel;
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value="PurchasePlan统计对象", description="PurchasePlan统计对象")
public class PurchasePlanStatisticsVO extends PurchasePlan {
/**物料编号*/
@Excel(name = "物料编号", width = 15)
@ApiModelProperty(value = "物料名称")
private String sparepartName;
@ApiModelProperty(value = "物料名称")
private String applyUserName;
/**计划采购数量*/
@Excel(name = "计划采购数量", width = 15)
@ApiModelProperty(value = "计划采购数量")
private String purchaseNum;
/**单价*/
@Excel(name = "单价", width = 15)
@ApiModelProperty(value = "单价")
private String unitPrice;
@Excel(name = "总价", width = 15)
@ApiModelProperty(value = "总价")
private String totalPrice;
}
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!