Skip to content

Commit ff21237

Browse files
committed
优化采è´申请查询
1 parent 63c997e commit ff21237

9 files changed

Lines changed: 166 additions & 32 deletions

File tree

Api/src/main/java/com/java110/api/listener/purchaseApply/ListPurchaseApplysListener.java

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -73,37 +73,22 @@ protected void doSoService(ServiceDataFlowEvent event, DataFlowContext context,
7373

7474
List<ApiPurchaseApplyDataVo> purchaseApplys = null;
7575
if (count > 0) {
76-
purchaseApplys = BeanConvertUtil.covertBeanList(purchaseApplyInnerServiceSMOImpl.queryPurchaseApplys(purchaseApplyDto), ApiPurchaseApplyDataVo.class);
77-
List<String> orderIds = new ArrayList<>();
78-
for( ApiPurchaseApplyDataVo apiPurchaseApplyDataVo : purchaseApplys){
79-
orderIds.add(apiPurchaseApplyDataVo.getApplyOrderId());
80-
}
81-
//明细列表
82-
PurchaseApplyDetailDto purchaseApplyDetailDto = new PurchaseApplyDetailDto();
83-
purchaseApplyDetailDto.setApplyOrderIds(orderIds);
84-
List<PurchaseApplyDetailVo> purchaseApplyDetailVos = BeanConvertUtil.covertBeanList(purchaseApplyInnerServiceSMOImpl.queryPurchaseApplyDetails(purchaseApplyDetailDto), PurchaseApplyDetailVo.class);
85-
86-
for( ApiPurchaseApplyDataVo apiPurchaseApplyDataVo : purchaseApplys){
87-
List<PurchaseApplyDetailVo> applyDetailList = new ArrayList<>();
88-
for( PurchaseApplyDetailVo purchaseApplyDetailVo : purchaseApplyDetailVos){
89-
if(apiPurchaseApplyDataVo.getApplyOrderId().equals(purchaseApplyDetailVo.getApplyOrderId())){
90-
applyDetailList.add(purchaseApplyDetailVo);
91-
}
92-
}
93-
apiPurchaseApplyDataVo.setPurchaseApplyDetailVo(applyDetailList);
94-
}
76+
List<PurchaseApplyDto> purchaseApplyDtos = purchaseApplyInnerServiceSMOImpl.queryPurchaseApplyAndDetails(purchaseApplyDto);
77+
purchaseApplys = BeanConvertUtil.covertBeanList(purchaseApplyDtos, ApiPurchaseApplyDataVo.class);
9578
for( ApiPurchaseApplyDataVo apiPurchaseApplyDataVo : purchaseApplys){
9679
List<PurchaseApplyDetailVo> applyDetailList = apiPurchaseApplyDataVo.getPurchaseApplyDetailVo();
97-
StringBuffer resNames = new StringBuffer();
98-
BigDecimal totalPrice = new BigDecimal(0);
99-
for( PurchaseApplyDetailVo purchaseApplyDetailVo : applyDetailList){
100-
resNames.append(purchaseApplyDetailVo.getResName()+";");
101-
BigDecimal price = new BigDecimal(purchaseApplyDetailVo.getPrice());
102-
BigDecimal quantity = new BigDecimal(purchaseApplyDetailVo.getQuantity());
103-
totalPrice = totalPrice.add(price.multiply(quantity));
80+
if(applyDetailList.size() > 0){
81+
StringBuffer resNames = new StringBuffer();
82+
BigDecimal totalPrice = new BigDecimal(0);
83+
for( PurchaseApplyDetailVo purchaseApplyDetailVo : applyDetailList){
84+
resNames.append(purchaseApplyDetailVo.getResName()+";");
85+
BigDecimal price = new BigDecimal(purchaseApplyDetailVo.getPrice());
86+
BigDecimal quantity = new BigDecimal(purchaseApplyDetailVo.getQuantity());
87+
totalPrice = totalPrice.add(price.multiply(quantity));
88+
}
89+
apiPurchaseApplyDataVo.setResourceNames(resNames.toString());
90+
apiPurchaseApplyDataVo.setTotalPrice(totalPrice.toString());
10491
}
105-
apiPurchaseApplyDataVo.setResourceNames(resNames.toString());
106-
apiPurchaseApplyDataVo.setTotalPrice(totalPrice.toString());
10792
}
10893
} else {
10994
purchaseApplys = new ArrayList<>();

StoreService/src/main/java/com/java110/store/dao/IPurchaseApplyServiceDao.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.java110.store.dao;
22

33

4+
import com.java110.dto.purchaseApply.PurchaseApplyDto;
45
import com.java110.utils.exception.DAOException;
56
import com.java110.vo.api.purchaseApply.PurchaseApplyDetailVo;
67

@@ -68,6 +69,8 @@ public interface IPurchaseApplyServiceDao {
6869
*/
6970
List<Map> getPurchaseApplyInfo(Map info) throws DAOException;
7071

72+
List<PurchaseApplyDto> getPurchaseApplyInfo2(Map info) throws DAOException;
73+
7174

7275
//查询采购明细
7376
List<Map> getPurchaseApplyDetailInfo(Map info) throws DAOException;

StoreService/src/main/java/com/java110/store/dao/impl/PurchaseApplyServiceDaoImpl.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.alibaba.fastjson.JSONObject;
44
import com.java110.core.base.dao.BaseServiceDao;
5+
import com.java110.dto.purchaseApply.PurchaseApplyDto;
56
import com.java110.store.dao.IPurchaseApplyServiceDao;
67
import com.java110.utils.constant.ResponseConstant;
78
import com.java110.utils.exception.DAOException;
@@ -118,6 +119,15 @@ public List<Map> getPurchaseApplyInfo(Map info) throws DAOException {
118119
return businessPurchaseApplyInfos;
119120
}
120121

122+
@Override
123+
public List<PurchaseApplyDto> getPurchaseApplyInfo2(Map info) throws DAOException {
124+
logger.debug("查询采购申请信息 入参 info : {}",info);
125+
126+
List<PurchaseApplyDto> businessPurchaseApplyInfos = sqlSessionTemplate.selectList("purchaseApplyServiceDaoImpl.getPurchaseApplyInfo2",info);
127+
128+
return businessPurchaseApplyInfos;
129+
}
130+
121131
@Override
122132
public List<Map> getPurchaseApplyDetailInfo(Map info) throws DAOException {
123133
logger.debug("查询采购申请明细信息 入参 info : {}",info);

StoreService/src/main/java/com/java110/store/smo/impl/PurchaseApplyInnerServiceSMOImpl.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,34 @@ public List<PurchaseApplyDto> queryPurchaseApplys(@RequestBody PurchaseApplyDto
6161
return purchaseApplys;
6262
}
6363

64+
@Override
65+
public List<PurchaseApplyDto> queryPurchaseApplyAndDetails(@RequestBody PurchaseApplyDto purchaseApplyDto) {
66+
67+
//校验是否传了 分页信息
68+
69+
int page = purchaseApplyDto.getPage();
70+
71+
if (page != PageDto.DEFAULT_PAGE) {
72+
purchaseApplyDto.setPage((page - 1) * purchaseApplyDto.getRow());
73+
}
74+
75+
List<PurchaseApplyDto> purchaseApplys = BeanConvertUtil.covertBeanList(purchaseApplyServiceDaoImpl.getPurchaseApplyInfo2(BeanConvertUtil.beanCovertMap(purchaseApplyDto)), PurchaseApplyDto.class);
76+
77+
if (purchaseApplys == null || purchaseApplys.size() == 0) {
78+
return purchaseApplys;
79+
}
80+
81+
String[] userIds = getUserIds(purchaseApplys);
82+
//根据 userId 查询用户信息
83+
List<UserDto> users = userInnerServiceSMOImpl.getUserInfo(userIds);
84+
85+
for (PurchaseApplyDto purchaseApply : purchaseApplys) {
86+
refreshPurchaseApply(purchaseApply, users);
87+
}
88+
return purchaseApplys;
89+
}
90+
91+
6492
/**
6593
* 从用户列表中查询用户,将用户中的信息 刷新到 floor对象中
6694
*

StoreService/src/main/resources/application-dev.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jedis:
77
host: dev.redis.java110.com
88
port: 6379
99
timeout: 3000
10-
password:
10+
password: hc
1111

1212
eureka:
1313
instance:
@@ -36,6 +36,7 @@ spring:
3636
database: 0
3737
host: dev.redis.java110.com
3838
port: 6379
39+
password: hc
3940
pool:
4041
max-active: 300
4142
max-wait: 10000

java110-bean/src/main/java/com/java110/dto/purchaseApply/PurchaseApplyDto.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
package com.java110.dto.purchaseApply;
22

33
import com.java110.dto.PageDto;
4+
import com.java110.vo.api.purchaseApply.PurchaseApplyDetailVo;
45

56
import java.io.Serializable;
67
import java.util.Date;
8+
import java.util.List;
79

810
/**
911
* @ClassName FloorDto
@@ -18,12 +20,13 @@ public class PurchaseApplyDto extends PageDto implements Serializable {
1820
private String resOrderType;
1921
private String description;
2022
private String applyOrderId;
23+
private String bId;
2124
private String state;
2225
private String storeId;
2326
private String userName;
2427
private String userId;
2528
private String stateName;
26-
29+
private List<PurchaseApplyDetailVo> purchaseApplyDetailVo;
2730

2831
private Date createTime;
2932

@@ -37,6 +40,7 @@ public class PurchaseApplyDto extends PageDto implements Serializable {
3740

3841

3942

43+
4044
public String getResOrderType() {
4145
return resOrderType;
4246
}
@@ -157,4 +161,20 @@ public String getAuditMessage() {
157161
public void setAuditMessage(String auditMessage) {
158162
this.auditMessage = auditMessage;
159163
}
164+
165+
public List<PurchaseApplyDetailVo> getPurchaseApplyDetailVo() {
166+
return purchaseApplyDetailVo;
167+
}
168+
169+
public void setPurchaseApplyDetailVo(List<PurchaseApplyDetailVo> purchaseApplyDetailVo) {
170+
this.purchaseApplyDetailVo = purchaseApplyDetailVo;
171+
}
172+
173+
public String getbId() {
174+
return bId;
175+
}
176+
177+
public void setbId(String bId) {
178+
this.bId = bId;
179+
}
160180
}

java110-bean/src/main/java/com/java110/vo/api/purchaseApply/PurchaseApplyDetailVo.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public class PurchaseApplyDetailVo {
1515
private List<String> applyOrderIds;
1616
private String bId;
1717
private String operate;
18+
private String id;
1819

1920

2021
public String getApplyOrderId() {
@@ -104,6 +105,14 @@ public String getOperate() {
104105
public void setOperate(String operate) {
105106
this.operate = operate;
106107
}
108+
109+
public String getId() {
110+
return id;
111+
}
112+
113+
public void setId(String id) {
114+
this.id = id;
115+
}
107116
}
108117

109118

java110-core/src/main/java/com/java110/core/smo/purchaseApply/IPurchaseApplyInnerServiceSMO.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ public interface IPurchaseApplyInnerServiceSMO {
3232
@RequestMapping(value = "/queryPurchaseApplys", method = RequestMethod.POST)
3333
List<PurchaseApplyDto> queryPurchaseApplys(@RequestBody PurchaseApplyDto purchaseApplyDto);
3434

35+
36+
@RequestMapping(value = "/queryPurchaseApplyAndDetails", method = RequestMethod.POST)
37+
List<PurchaseApplyDto> queryPurchaseApplyAndDetails(@RequestBody PurchaseApplyDto purchaseApplyDto);
38+
3539
/**
3640
* 查询<p>小区楼</p>总记录数
3741
*

java110-db/src/main/resources/mapper/store/PurchaseApplyServiceDaoImplMapper.xml

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,33 @@
44
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
55
<mapper namespace="purchaseApplyServiceDaoImpl">
66

7+
8+
<resultMap type="com.java110.dto.purchaseApply.PurchaseApplyDto" id="applyMap">
9+
<id column="applyOrderId" property="applyOrderId"/>
10+
<result column="description" property="description"/>
11+
<result column="resOrderType" property="resOrderType"/>
12+
<result column="statusCd" property="statusCd"/>
13+
<result column="state" property="state"/>
14+
<result column="storeId" property="storeId"/>
15+
<result column="userName" property="userName"/>
16+
<result column="bId" property="bId"/>
17+
<result column="userId" property="userId"/>
18+
<result column="createTime" property="createTime"/>
19+
<result column="stateName" property="stateName"/>
20+
<!-- 一对多关系 -->
21+
<collection property="purchaseApplyDetailVo" ofType="com.java110.vo.api.purchaseApply.PurchaseApplyDetailVo" javaType="java.util.ArrayList">
22+
<id property="id" column="id"/>
23+
<result property="applyOrderId" column="applyOrderId"/>
24+
<result property="resId" column="resId"/>
25+
<result property="quantity" column="quantity"/>
26+
<result property="resName" column="resName"/>
27+
<result property="remark" column="remark"/>
28+
<result property="resCode" column="resCode"/>
29+
<result property="price" column="price"/>
30+
<result property="stock" column="stock"/>
31+
</collection>
32+
</resultMap>
33+
734
<!-- 保存采购申请信息 add by wuxw 2018-07-03 -->
835
<insert id="saveBusinessPurchaseApplyInfo" parameterType="Map">
936
insert into business_purchase_apply
@@ -144,8 +171,9 @@
144171
t.res_order_type resOrderType,t.description,
145172
t.apply_order_id applyOrderId,t.status_cd statusCd,t.state,
146173
t.store_id storeId,t.user_name userName,
147-
t.b_id bId,t.user_id userId,t.create_time createTime,d.name stateName
148-
from purchase_apply t inner join t_dict d on t.state = d.status_cd and d.table_name = 'purchase_apply' and d.table_columns = 'state'
174+
t.b_id bId,t.user_id userId,t.create_time createTime,d.name stateName,
175+
from purchase_apply t
176+
inner join t_dict d on t.state = d.status_cd and d.table_name = 'purchase_apply' and d.table_columns = 'state'
149177
where 1 =1
150178
<if test="resOrderType !=null and resOrderType != ''">
151179
and t.res_order_type= #{resOrderType}
@@ -179,6 +207,52 @@
179207

180208
</select>
181209

210+
211+
212+
<select id="getPurchaseApplyInfo2" parameterType="Map" resultMap="applyMap">
213+
select
214+
t.res_order_type resOrderType,t.description,
215+
t.apply_order_id applyOrderId,t.status_cd statusCd,t.state,
216+
t.store_id storeId,t.user_name userName,
217+
t.b_id bId,t.user_id userId,t.create_time createTime,d.name stateName,
218+
de.apply_order_id applyOrderId,de.res_id resId,de.quantity,de.remark,de.id,rs.res_name resName,rs.price,rs.stock,rs.res_code resCode
219+
from purchase_apply t
220+
inner join t_dict d on t.state = d.status_cd and d.table_name = 'purchase_apply' and d.table_columns = 'state'
221+
inner join purchase_apply_detail de on de.apply_order_id = t.apply_order_id
222+
inner join resource_store rs on de.res_id = rs.res_id
223+
224+
where 1 =1
225+
<if test="resOrderType !=null and resOrderType != ''">
226+
and t.res_order_type= #{resOrderType}
227+
</if>
228+
<if test="description !=null and description != ''">
229+
and t.description= #{description}
230+
</if>
231+
<if test="applyOrderId !=null and applyOrderId != ''">
232+
and t.apply_order_id= #{applyOrderId}
233+
</if>
234+
<if test="userName !=null and userName != ''">
235+
and t.user_name like concat('%',#{userName},'%')
236+
</if>
237+
<if test="statusCd !=null and statusCd != ''">
238+
and t.status_cd= #{statusCd}
239+
</if>
240+
<if test="state !=null and state != ''">
241+
and t.state= #{state}
242+
</if>
243+
<if test="storeId !=null and storeId != ''">
244+
and t.store_id= #{storeId}
245+
</if>
246+
<if test="bId !=null and bId != ''">
247+
and t.b_id= #{bId}
248+
</if>
249+
250+
order by t.create_time desc
251+
<if test="page != -1 and page != null ">
252+
limit #{page}, #{row}
253+
</if>
254+
255+
</select>
182256
<!-- 查询采购明细 -->
183257
<select id="getPurchaseApplyDetailInfo" parameterType="Map" resultType="Map">
184258
select

0 commit comments

Comments
 (0)