7a610143 康伟

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

1 个父辈 47cbed7d
...@@ -22,10 +22,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -22,10 +22,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
22 import com.baomidou.mybatisplus.core.metadata.IPage; 22 import com.baomidou.mybatisplus.core.metadata.IPage;
23 import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 23 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
24 import com.skua.modules.erp.vo.PurchasePlanSearchVO; 24 import com.skua.modules.erp.vo.PurchasePlanSearchVO;
25 import com.skua.modules.erp.vo.PurchasePlanStatisticsVO;
25 import com.skua.modules.erp.vo.PurchasePlanVO; 26 import com.skua.modules.erp.vo.PurchasePlanVO;
26 import com.skua.modules.guest.util.DateUtil; 27 import com.skua.modules.guest.util.DateUtil;
28 import com.skua.modules.supplies.service.IEquipmentSparepartTypeService;
27 import lombok.extern.slf4j.Slf4j; 29 import lombok.extern.slf4j.Slf4j;
28 30
31 import org.apache.commons.lang3.StringUtils;
29 import org.jeecgframework.poi.excel.ExcelImportUtil; 32 import org.jeecgframework.poi.excel.ExcelImportUtil;
30 import org.jeecgframework.poi.excel.def.NormalExcelConstants; 33 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
31 import org.jeecgframework.poi.excel.entity.ExportParams; 34 import org.jeecgframework.poi.excel.entity.ExportParams;
...@@ -55,6 +58,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -55,6 +58,8 @@ import io.swagger.annotations.ApiOperation;
55 public class PurchasePlanController { 58 public class PurchasePlanController {
56 @Autowired 59 @Autowired
57 private IPurchasePlanService purchasePlanService; 60 private IPurchasePlanService purchasePlanService;
61 @Autowired
62 private IEquipmentSparepartTypeService equipmentSparepartTypeService;
58 63
59 @AutoLog(value = "erp采购计划表-分页列表查询") 64 @AutoLog(value = "erp采购计划表-分页列表查询")
60 @ApiOperation(value="erp采购计划表-分页列表查询", notes="erp采购计划表-分页列表查询") 65 @ApiOperation(value="erp采购计划表-分页列表查询", notes="erp采购计划表-分页列表查询")
...@@ -66,22 +71,20 @@ public class PurchasePlanController { ...@@ -66,22 +71,20 @@ public class PurchasePlanController {
66 Result<IPage<PurchasePlan>> result = new Result<IPage<PurchasePlan>>(); 71 Result<IPage<PurchasePlan>> result = new Result<IPage<PurchasePlan>>();
67 QueryWrapper<PurchasePlan> queryWrapper = QueryGenerator.initQueryWrapper(purchasePlan, req.getParameterMap()); 72 QueryWrapper<PurchasePlan> queryWrapper = QueryGenerator.initQueryWrapper(purchasePlan, req.getParameterMap());
68 Page<PurchasePlan> page = new Page<PurchasePlan>(pageNo, pageSize); 73 Page<PurchasePlan> page = new Page<PurchasePlan>(pageNo, pageSize);
69 /*if(purchasePlanVO.getDepartId() != null ){ 74 if(StringUtils.isNotEmpty( purchasePlan.getDepartId() ) ){
70 queryWrapper.eq("depart_id", purchasePlanVO.getDepartId()); 75 queryWrapper.eq("depart_id", purchasePlan.getDepartId());
71 } 76 }
72 if(purchasePlanVO.getStatus() != null ){ 77 if(StringUtils.isNotEmpty( purchasePlan.getStatus() ) ){
73 queryWrapper.eq("status", purchasePlanVO.getStatus()); 78 queryWrapper.eq("status", purchasePlan.getStatus());
74 } 79 }
75 80
76 if(purchasePlanVO.getApplyYear() != null ){ 81 if( StringUtils.isNotEmpty( purchasePlan.getApplyYear() ) ){
77 queryWrapper.eq("apply_year", purchasePlanVO.getApplyYear()); 82 queryWrapper.eq("apply_year", purchasePlan.getApplyYear());
78 } 83 }
79 if(purchasePlanVO.getApplyYear() != null ){ 84
80 queryWrapper.eq("apply_year", purchasePlanVO.getApplyYear()); 85 if(StringUtils.isNotEmpty( purchasePlan.getApplyUser()) ){
86 queryWrapper.like("apply_user", purchasePlan.getApplyUser());
81 } 87 }
82 if(purchasePlanVO.getApplyUser() != null ){
83 queryWrapper.like("apply_user", purchasePlanVO.getApplyUser());
84 }*/
85 queryWrapper.orderByDesc("create_time"); 88 queryWrapper.orderByDesc("create_time");
86 89
87 IPage<PurchasePlan> pageList = purchasePlanService.page(page, queryWrapper); 90 IPage<PurchasePlan> pageList = purchasePlanService.page(page, queryWrapper);
...@@ -102,24 +105,28 @@ public class PurchasePlanController { ...@@ -102,24 +105,28 @@ public class PurchasePlanController {
102 QueryWrapper<PurchasePlan> queryWrapper = QueryGenerator.initQueryWrapper(purchasePlan, req.getParameterMap()); 105 QueryWrapper<PurchasePlan> queryWrapper = QueryGenerator.initQueryWrapper(purchasePlan, req.getParameterMap());
103 Page<PurchasePlan> page = new Page<PurchasePlan>(pageNo, pageSize); 106 Page<PurchasePlan> page = new Page<PurchasePlan>(pageNo, pageSize);
104 107
105 /* queryWrapper.in("depart_id", BaseContextHandler.getDeparts().split(","));
106 108
107 if(purchasePlan.getStatus() != null ){ 109 if(StringUtils.isNotEmpty( purchasePlan.getDepartId() ) ){
108 queryWrapper.eq("status", purchasePlan.getStatus()); 110 queryWrapper.eq("depart_id", purchasePlan.getDepartId());
111 }else{
112 //如果为管理员,则跳过权限
113 if (!"1".equals(BaseContextHandler.get("userType"))) {
114 queryWrapper.in("depart_id", BaseContextHandler.getDeparts().split(","));
115 }
109 } 116 }
110 117
111 if(purchasePlan.getApplyYear() != null ){ 118 if(StringUtils.isNotEmpty( purchasePlan.getStatus() ) ){
112 queryWrapper.eq("apply_year", purchasePlan.getApplyYear()); 119 queryWrapper.eq("status", purchasePlan.getStatus());
120 }else{
121 queryWrapper.gt("status" , "0");// >0
122 queryWrapper.ne("status" , "2"); // 不等于2
113 } 123 }
114 if(purchasePlan.getApplyYear() != null ){ 124 if( StringUtils.isNotEmpty( purchasePlan.getApplyYear()) ){
115 queryWrapper.eq("apply_year", purchasePlan.getApplyYear()); 125 queryWrapper.eq("apply_year", purchasePlan.getApplyYear());
116 } 126 }
117 if(purchasePlan.getApplyUser() != null ){ 127 if( StringUtils.isNotEmpty( purchasePlan.getApplyUser() ) ){
118 queryWrapper.like("apply_user", purchasePlan.getApplyUser()); 128 queryWrapper.like("apply_user", purchasePlan.getApplyUser());
119 }*/ 129 }
120 queryWrapper.in("depart_id", BaseContextHandler.getDeparts().split(","));
121 queryWrapper.gt("status" , "0");// >0
122 queryWrapper.ne("status" , "2"); // 不等于2
123 queryWrapper.orderByDesc("create_time"); 130 queryWrapper.orderByDesc("create_time");
124 IPage<PurchasePlan> pageList = purchasePlanService.page(page, queryWrapper); 131 IPage<PurchasePlan> pageList = purchasePlanService.page(page, queryWrapper);
125 result.setSuccess(true); 132 result.setSuccess(true);
...@@ -292,6 +299,20 @@ public class PurchasePlanController { ...@@ -292,6 +299,20 @@ public class PurchasePlanController {
292 Page<PurchasePlanItem> page = new Page<PurchasePlanItem>(pageNo, pageSize); 299 Page<PurchasePlanItem> page = new Page<PurchasePlanItem>(pageNo, pageSize);
293 //purchasePlanSearchVO.setDepats(); 300 //purchasePlanSearchVO.setDepats();
294 purchasePlanSearchVO.setDeparts(BaseContextHandler.getDeparts()); 301 purchasePlanSearchVO.setDeparts(BaseContextHandler.getDeparts());
302
303
304 Set<String> sparepartTypeSet = new HashSet<>();
305 String sparepartTypeStr = "";
306 if (StringUtils.isNotEmpty(purchasePlanSearchVO.getSparepartType())) {
307 // 查询子集
308 sparepartTypeSet = equipmentSparepartTypeService.getAllChildrenSparepartTypeIds( purchasePlanSearchVO.getSparepartType() );
309 if(sparepartTypeSet.size() > 0 ){
310 // 使用String.join()方法转换Set为字符串,以逗号分隔
311 sparepartTypeStr = String.join(",", sparepartTypeSet);
312 }
313 purchasePlanSearchVO.setSparepartType( sparepartTypeStr );
314 }
315
295 IPage<PurchasePlanItem> pageList = purchasePlanService.statisticsPage(page,purchasePlanSearchVO); 316 IPage<PurchasePlanItem> pageList = purchasePlanService.statisticsPage(page,purchasePlanSearchVO);
296 result.setSuccess(true); 317 result.setSuccess(true);
297 result.setResult(pageList); 318 result.setResult(pageList);
...@@ -301,15 +322,15 @@ public class PurchasePlanController { ...@@ -301,15 +322,15 @@ public class PurchasePlanController {
301 @AutoLog(value = "erp采购计划表-统计详情") 322 @AutoLog(value = "erp采购计划表-统计详情")
302 @ApiOperation(value="erp采购计划表-统计详情", notes="erp采购计划表-统计详情") 323 @ApiOperation(value="erp采购计划表-统计详情", notes="erp采购计划表-统计详情")
303 @GetMapping(value = "/statisticsDetail") 324 @GetMapping(value = "/statisticsDetail")
304 public Result<IPage<PurchasePlanItem>> statisticsDetail(PurchasePlanSearchVO purchasePlanSearchVO, 325 public Result<IPage<PurchasePlanStatisticsVO>> statisticsDetail(PurchasePlanSearchVO purchasePlanSearchVO,
305 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo, 326 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
306 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize, 327 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
307 HttpServletRequest req) { 328 HttpServletRequest req) {
308 Result<IPage<PurchasePlanItem>> result = new Result<IPage<PurchasePlanItem>>(); 329 Result<IPage<PurchasePlanStatisticsVO>> result = new Result<IPage<PurchasePlanStatisticsVO>>();
309 330
310 Page<PurchasePlanItem> page = new Page<PurchasePlanItem>(pageNo, pageSize); 331 Page<PurchasePlanStatisticsVO> page = new Page<PurchasePlanStatisticsVO>(pageNo, pageSize);
311 purchasePlanSearchVO.setDeparts(BaseContextHandler.getDeparts()); 332 //purchasePlanSearchVO.setDeparts(BaseContextHandler.getDeparts());
312 IPage<PurchasePlanItem> pageList = purchasePlanService.statisticsPageBySparepartId(page,purchasePlanSearchVO); 333 IPage<PurchasePlanStatisticsVO> pageList = purchasePlanService.statisticsPageBySparepartId(page,purchasePlanSearchVO);
313 result.setSuccess(true); 334 result.setSuccess(true);
314 result.setResult(pageList); 335 result.setResult(pageList);
315 return result; 336 return result;
......
...@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; ...@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7 import com.skua.modules.erp.entity.PurchaseMaterial; 7 import com.skua.modules.erp.entity.PurchaseMaterial;
8 import com.skua.modules.erp.entity.PurchasePlanItem; 8 import com.skua.modules.erp.entity.PurchasePlanItem;
9 import com.skua.modules.erp.vo.PurchasePlanSearchVO; 9 import com.skua.modules.erp.vo.PurchasePlanSearchVO;
10 import com.skua.modules.erp.vo.PurchasePlanStatisticsVO;
10 import org.apache.ibatis.annotations.Param; 11 import org.apache.ibatis.annotations.Param;
11 import com.skua.modules.erp.entity.PurchasePlan; 12 import com.skua.modules.erp.entity.PurchasePlan;
12 import com.baomidou.mybatisplus.core.mapper.BaseMapper; 13 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...@@ -30,6 +31,6 @@ public interface PurchasePlanMapper extends BaseMapper<PurchasePlan> { ...@@ -30,6 +31,6 @@ public interface PurchasePlanMapper extends BaseMapper<PurchasePlan> {
30 * @param page 31 * @param page
31 * @return 32 * @return
32 */ 33 */
33 IPage<PurchasePlanItem> statisticsPageBySparepartId(Page<PurchasePlanItem> page, @Param("ev")PurchasePlanSearchVO purchasePlanSearchVO); 34 IPage<PurchasePlanStatisticsVO> statisticsPageBySparepartId(Page<PurchasePlanStatisticsVO> page, @Param("ev")PurchasePlanSearchVO purchasePlanSearchVO);
34 35
35 } 36 }
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
3 <mapper namespace="com.skua.modules.erp.mapper.PurchasePlanMapper"> 3 <mapper namespace="com.skua.modules.erp.mapper.PurchasePlanMapper">
4 <!-- 统计查询--> 4 <!-- 统计查询-->
5 <select id="statisticsPage" resultType="com.skua.modules.erp.entity.PurchasePlanItem"> 5 <select id="statisticsPage" resultType="com.skua.modules.erp.entity.PurchasePlanItem">
6 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 ( 6 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 (
7 select pi.sparepart_id,sum(pi.purchase_num ) as 'purchase_num' , sum(pi.total_price) 'total_price' 7 select pi.sparepart_id,sum(pi.purchase_num ) as 'purchase_num' , sum(pi.total_price) 'total_price'
8 from erp_purchase_plan_item pi ,erp_purchase_plan pp 8 from erp_purchase_plan_item pi ,erp_purchase_plan pp
9 where 9 where
10 pp.id = pi.plan_id 10 pp.id = pi.plan_id
11 <if test="ev.sparepartType != null and ev.sparepartType != '' "> 11 <if test="ev.sparepartType != null and ev.sparepartType != '' ">
12 and pi.sparepart_type = #{ev.sparepartType} 12 and pi.sparepart_type in ( ${ev.sparepartType})
13 </if> 13 </if>
14 <if test="ev.sparepartCode != null and ev.sparepartCode != '' "> 14 <if test="ev.sparepartCode != null and ev.sparepartCode != '' ">
15 AND pi.sparepart_code like concat('%', #{ev.sparepartCode}, '%') 15 AND pi.sparepart_code like concat('%', #{ev.sparepartCode}, '%')
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
21 and pp.apply_year = #{ev.applyYear} 21 and pp.apply_year = #{ev.applyYear}
22 </if> 22 </if>
23 <if test="ev.departId != null and ev.departId!= ''"> 23 <if test="ev.departId != null and ev.departId!= ''">
24 and pp.depart_id = #{ev.departId} 24 and pp.depart_id in ( ${ev.departId} )
25 </if> 25 </if>
26 <if test="ev.startTime != null and ev.startTime!= ''"> 26 <if test="ev.startTime != null and ev.startTime!= ''">
27 and pp.apply_time &gt;= #{ev.startTime} 27 and pp.apply_time &gt;= #{ev.startTime}
...@@ -36,10 +36,10 @@ ...@@ -36,10 +36,10 @@
36 36
37 </select> 37 </select>
38 38
39 <select id="statisticsPageBySparepartId" resultType="com.skua.modules.erp.entity.PurchasePlanItem"> 39 <select id="statisticsPageBySparepartId" resultType="com.skua.modules.erp.vo.PurchasePlanStatisticsVO">
40 select st.item_text as 'sparepart_type_name' , d.depart_name , aaa.* 40
41 from ( 41 select u.realname 'apply_user_name', aaa.* from (
42 select pi.* ,pp.depart_id 42 select pi.purchase_num ,pi.measuring_unit,pi.sparepart_name, pi.unit_price , pi.total_price , pp.*
43 from erp_purchase_plan_item pi ,erp_purchase_plan pp 43 from erp_purchase_plan_item pi ,erp_purchase_plan pp
44 where pp.id = pi.plan_id and pi.sparepart_id=#{ev.sparepartId} 44 where pp.id = pi.plan_id and pi.sparepart_id=#{ev.sparepartId}
45 <if test="ev.sparepartType != null and ev.sparepartType != '' "> 45 <if test="ev.sparepartType != null and ev.sparepartType != '' ">
...@@ -59,10 +59,9 @@ ...@@ -59,10 +59,9 @@
59 <if test="ev.endTime != null and ev.endTime != ''"> 59 <if test="ev.endTime != null and ev.endTime != ''">
60 and pp.apply_time &lt;= #{ev.endTime} 60 and pp.apply_time &lt;= #{ev.endTime}
61 </if> 61 </if>
62
63 )aaa 62 )aaa
64 left join equipment_sparepart_type st on st.id = aaa.sparepart_type
65 left join sys_depart d on d.id = aaa.depart_id 63 left join sys_depart d on d.id = aaa.depart_id
64 left join sys_user u on u.id = aaa.apply_user
66 </select> 65 </select>
67 <!-- and pp.depart_id in (#{ev.departs})--> 66 <!-- and pp.depart_id in (#{ev.departs})-->
68 </mapper> 67 </mapper>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,6 +6,7 @@ import com.skua.modules.erp.entity.PurchasePlan; ...@@ -6,6 +6,7 @@ import com.skua.modules.erp.entity.PurchasePlan;
6 import com.baomidou.mybatisplus.extension.service.IService; 6 import com.baomidou.mybatisplus.extension.service.IService;
7 import com.skua.modules.erp.entity.PurchasePlanItem; 7 import com.skua.modules.erp.entity.PurchasePlanItem;
8 import com.skua.modules.erp.vo.PurchasePlanSearchVO; 8 import com.skua.modules.erp.vo.PurchasePlanSearchVO;
9 import com.skua.modules.erp.vo.PurchasePlanStatisticsVO;
9 import com.skua.modules.erp.vo.PurchasePlanVO; 10 import com.skua.modules.erp.vo.PurchasePlanVO;
10 11
11 import java.util.List; 12 import java.util.List;
...@@ -69,6 +70,6 @@ public interface IPurchasePlanService extends IService<PurchasePlan> { ...@@ -69,6 +70,6 @@ public interface IPurchasePlanService extends IService<PurchasePlan> {
69 * @param page 70 * @param page
70 * @return 71 * @return
71 */ 72 */
72 IPage<PurchasePlanItem> statisticsPageBySparepartId(Page<PurchasePlanItem> page, PurchasePlanSearchVO purchasePlanSearchVO); 73 IPage<PurchasePlanStatisticsVO> statisticsPageBySparepartId(Page<PurchasePlanStatisticsVO> page, PurchasePlanSearchVO purchasePlanSearchVO);
73 74
74 } 75 }
......
...@@ -12,6 +12,7 @@ import com.skua.modules.erp.mapper.PurchasePlanItemMapper; ...@@ -12,6 +12,7 @@ import com.skua.modules.erp.mapper.PurchasePlanItemMapper;
12 import com.skua.modules.erp.mapper.PurchasePlanMapper; 12 import com.skua.modules.erp.mapper.PurchasePlanMapper;
13 import com.skua.modules.erp.service.IPurchasePlanService; 13 import com.skua.modules.erp.service.IPurchasePlanService;
14 import com.skua.modules.erp.vo.PurchasePlanSearchVO; 14 import com.skua.modules.erp.vo.PurchasePlanSearchVO;
15 import com.skua.modules.erp.vo.PurchasePlanStatisticsVO;
15 import com.skua.modules.erp.vo.PurchasePlanVO; 16 import com.skua.modules.erp.vo.PurchasePlanVO;
16 import org.springframework.beans.BeanUtils; 17 import org.springframework.beans.BeanUtils;
17 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
...@@ -167,7 +168,7 @@ public class PurchasePlanServiceImpl extends ServiceImpl<PurchasePlanMapper, Pur ...@@ -167,7 +168,7 @@ public class PurchasePlanServiceImpl extends ServiceImpl<PurchasePlanMapper, Pur
167 * @param page 168 * @param page
168 * @return 169 * @return
169 */ 170 */
170 public IPage<PurchasePlanItem> statisticsPageBySparepartId(Page<PurchasePlanItem> page, PurchasePlanSearchVO purchasePlanSearchVO){ 171 public IPage<PurchasePlanStatisticsVO> statisticsPageBySparepartId(Page<PurchasePlanStatisticsVO> page, PurchasePlanSearchVO purchasePlanSearchVO){
171 return this.baseMapper.statisticsPageBySparepartId(page,purchasePlanSearchVO); 172 return this.baseMapper.statisticsPageBySparepartId(page,purchasePlanSearchVO);
172 } 173 }
173 } 174 }
......
1 package com.skua.modules.erp.vo;
2
3 import com.skua.modules.erp.entity.PurchasePlan;
4 import io.swagger.annotations.ApiModel;
5 import io.swagger.annotations.ApiModelProperty;
6 import lombok.Data;
7 import lombok.EqualsAndHashCode;
8 import lombok.experimental.Accessors;
9 import org.jeecgframework.poi.excel.annotation.Excel;
10
11 @Data
12 @EqualsAndHashCode(callSuper = false)
13 @Accessors(chain = true)
14 @ApiModel(value="PurchasePlan统计对象", description="PurchasePlan统计对象")
15 public class PurchasePlanStatisticsVO extends PurchasePlan {
16 /**物料编号*/
17 @Excel(name = "物料编号", width = 15)
18 @ApiModelProperty(value = "物料名称")
19 private String sparepartName;
20
21 @ApiModelProperty(value = "物料名称")
22 private String applyUserName;
23
24
25 /**计划采购数量*/
26 @Excel(name = "计划采购数量", width = 15)
27 @ApiModelProperty(value = "计划采购数量")
28 private String purchaseNum;
29 /**单价*/
30 @Excel(name = "单价", width = 15)
31 @ApiModelProperty(value = "单价")
32 private String unitPrice;
33
34
35 @Excel(name = "总价", width = 15)
36 @ApiModelProperty(value = "总价")
37 private String totalPrice;
38 }
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!