Commit 4fe232dc8cd999465d37edd408f1d3f175a68733

Authored by 房远帅
1 parent 9559ed67

楚江ERP:订货单-增、删、改、查接口调试

... ... @@ -5,7 +5,10 @@ import com.fasterxml.jackson.annotation.JsonFormat;
5 5 import com.lframework.starter.common.constants.StringPool;
6 6 import com.lframework.starter.web.core.bo.BaseBo;
7 7 import java.time.LocalDate;
  8 +import java.util.List;
  9 +
8 10 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
  11 +import com.lframework.xingyun.sc.entity.PurchaseOrderLine;
9 12 import io.swagger.annotations.ApiModelProperty;
10 13
11 14 import lombok.Data;
... ... @@ -200,6 +203,12 @@ public class GetPurchaseOrderInfoBo extends BaseBo<PurchaseOrderInfo> {
200 203 @ApiModelProperty("实际订货数量")
201 204 private String actualOrderNumber;
202 205
  206 + /**
  207 + * 订货单表物料行
  208 + */
  209 + @ApiModelProperty("订货单表物料行")
  210 + private List<PurchaseOrderLine> purchaseOrderLineList;
  211 +
203 212
204 213
205 214 public GetPurchaseOrderInfoBo() {
... ...
... ... @@ -5,12 +5,17 @@ import com.lframework.starter.web.core.controller.DefaultBaseController;
5 5 import com.lframework.starter.web.core.utils.PageResultUtil;
6 6 import com.lframework.starter.web.core.components.resp.PageResult;
7 7 import com.lframework.starter.web.core.components.resp.InvokeResult;
  8 +
  9 +import javax.annotation.Resource;
8 10 import javax.validation.constraints.NotBlank;
9 11 import com.lframework.xingyun.sc.bo.order.GetPurchaseOrderInfoBo;
10 12 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
  13 +import com.lframework.xingyun.sc.entity.PurchaseOrderLine;
11 14 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
  15 +import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
12 16 import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderInfoVo;
13 17 import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderInfoVo;
  18 +import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderLineVo;
14 19 import com.lframework.xingyun.sc.vo.order.UpdatePurchaseOrderInfoVo;
15 20 import io.swagger.annotations.ApiImplicitParam;
16 21 import com.lframework.starter.web.core.components.resp.InvokeResultBuilder;
... ... @@ -18,6 +23,7 @@ import com.lframework.starter.common.exceptions.impl.DefaultClientException;
18 23 import io.swagger.annotations.ApiOperation;
19 24 import com.lframework.starter.common.utils.CollectionUtil;
20 25 import io.swagger.annotations.Api;
  26 +import org.springframework.security.core.parameters.P;
21 27 import org.springframework.web.bind.annotation.DeleteMapping;
22 28 import org.springframework.beans.factory.annotation.Autowired;
23 29 import org.springframework.validation.annotation.Validated;
... ... @@ -39,7 +45,8 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
39 45
40 46 @Autowired
41 47 private PurchaseOrderInfoService purchaseOrderInfoService;
42   -
  48 + @Resource
  49 + private PurchaseOrderLineService purchaseOrderLineService;
43 50 /**
44 51 * 查询列表
45 52 */
... ... @@ -66,7 +73,7 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
66 73 @ApiOperation("根据ID查询")
67 74 @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true)
68 75 @HasPermission({"purchaseOrderInfo:purchaseorderinfo:query"})
69   - @GetMapping
  76 + @GetMapping("/get")
70 77 public InvokeResult<GetPurchaseOrderInfoBo> get(@NotBlank(message = "id不能为空!") String id) {
71 78
72 79 PurchaseOrderInfo data = purchaseOrderInfoService.findById(id);
... ... @@ -75,6 +82,13 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
75 82 }
76 83
77 84 GetPurchaseOrderInfoBo result = new GetPurchaseOrderInfoBo(data);
  85 + QueryPurchaseOrderLineVo vo = new QueryPurchaseOrderLineVo();
  86 + vo.setPurchaseOrderId(id);
  87 + List<PurchaseOrderLine> purchaseOrderLineList = purchaseOrderLineService.query(vo);
  88 + if (CollectionUtil.isNotEmpty(purchaseOrderLineList)) {
  89 + result.setPurchaseOrderLineList(purchaseOrderLineList);
  90 + }
  91 +
78 92
79 93 return InvokeResultBuilder.success(result);
80 94 }
... ... @@ -84,8 +98,8 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
84 98 */
85 99 @ApiOperation("新增")
86 100 @HasPermission({"purchaseOrderInfo:purchaseorderinfo:add"})
87   - @PostMapping
88   - public InvokeResult<Void> create(@Valid CreatePurchaseOrderInfoVo vo) {
  101 + @PostMapping("/create")
  102 + public InvokeResult<Void> create(@Valid @RequestBody CreatePurchaseOrderInfoVo vo) {
89 103
90 104 purchaseOrderInfoService.create(vo);
91 105
... ... @@ -97,8 +111,8 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
97 111 */
98 112 @ApiOperation("修改")
99 113 @HasPermission({"purchaseOrderInfo:purchaseorderinfo:modify"})
100   - @PutMapping
101   - public InvokeResult<Void> update(@Valid UpdatePurchaseOrderInfoVo vo) {
  114 + @PutMapping("/update")
  115 + public InvokeResult<Void> update(@Valid @RequestBody UpdatePurchaseOrderInfoVo vo) {
102 116
103 117 purchaseOrderInfoService.update(vo);
104 118
... ... @@ -111,7 +125,7 @@ public class PurchaseOrderInfoController extends DefaultBaseController {
111 125 @ApiOperation("根据ID删除")
112 126 @ApiImplicitParam(value = "id", name = "id", paramType = "query", required = true)
113 127 @HasPermission({"purchaseOrderInfo:purchaseorderinfo:delete"})
114   - @DeleteMapping
  128 + @DeleteMapping("/deleteById")
115 129 public InvokeResult<Void> deleteById(@NotBlank(message = "id不能为空!") String id) {
116 130
117 131 purchaseOrderInfoService.deleteById(id);
... ...
... ... @@ -16,14 +16,14 @@ import com.lframework.starter.web.core.annotations.oplog.OpLog;
16 16 import com.lframework.starter.web.core.utils.PageHelperUtil;
17 17 import com.lframework.starter.common.utils.Assert;
18 18 import com.lframework.starter.web.inner.components.oplog.OtherOpLogType;
  19 +import com.lframework.xingyun.sc.entity.CustomerCredit;
19 20 import com.lframework.xingyun.sc.entity.PurchaseOrderInfo;
20 21 import com.lframework.xingyun.sc.mappers.PurchaseOrderInfoMapper;
  22 +import com.lframework.xingyun.sc.service.customer.CustomerCreditService;
21 23 import com.lframework.xingyun.sc.service.order.PurchaseOrderInfoService;
22 24 import com.lframework.xingyun.sc.service.order.PurchaseOrderLineService;
23   -import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderInfoVo;
24   -import com.lframework.xingyun.sc.vo.order.CreatePurchaseOrderLineVo;
25   -import com.lframework.xingyun.sc.vo.order.QueryPurchaseOrderInfoVo;
26   -import com.lframework.xingyun.sc.vo.order.UpdatePurchaseOrderInfoVo;
  25 +import com.lframework.xingyun.sc.vo.customer.credit.QueryCustomerCreditVo;
  26 +import com.lframework.xingyun.sc.vo.order.*;
27 27 import org.apache.commons.collections.CollectionUtils;
28 28 import org.springframework.transaction.annotation.Transactional;
29 29 import org.springframework.stereotype.Service;
... ... @@ -37,6 +37,8 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
37 37
38 38 @Resource
39 39 private PurchaseOrderLineService purchaseOrderLineService;
  40 + @Resource
  41 + private CustomerCreditService customerCreditService;
40 42
41 43 @Override
42 44 public PageResult<PurchaseOrderInfo> query(Integer pageIndex, Integer pageSize, QueryPurchaseOrderInfoVo vo) {
... ... @@ -59,7 +61,7 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
59 61 @Override
60 62 public PurchaseOrderInfo findById(String id) {
61 63
62   - return getBaseMapper().selectById(id);
  64 + return getBaseMapper().findById(id);
63 65 }
64 66
65 67 @OpLog(type = OtherOpLogType.class, name = "新增订货单表,ID:{}", params = {"#id"})
... ... @@ -77,6 +79,15 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
77 79 }
78 80 if (!StringUtil.isBlank(vo.getOrderingUnit())) {
79 81 data.setOrderingUnit(vo.getOrderingUnit());
  82 + //根据客户id查出客户资信,资信状态不为取消
  83 + QueryCustomerCreditVo queryVo = new QueryCustomerCreditVo();
  84 + queryVo.setCompanyId(vo.getOrderingUnit());
  85 + queryVo.setStatusCancel("CANCEL");
  86 + List<CustomerCredit> query = customerCreditService.query(queryVo);
  87 + if (CollectionUtils.isNotEmpty(query)) {
  88 + CustomerCredit customerCredit = query.get(0);
  89 + data.setCustomerCreditId(customerCredit.getId());
  90 + }
80 91 }
81 92 if (vo.getOrderDate() != null) {
82 93 data.setOrderDate(vo.getOrderDate());
... ... @@ -135,9 +146,6 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
135 146 if (!StringUtil.isBlank(vo.getWorkshopId())) {
136 147 data.setWorkshopId(vo.getWorkshopId());
137 148 }
138   - if (!StringUtil.isBlank(vo.getCustomerCreditId())) {
139   - data.setCustomerCreditId(vo.getCustomerCreditId());
140   - }
141 149
142 150 getBaseMapper().insert(data);
143 151
... ... @@ -194,6 +202,14 @@ public class PurchaseOrderInfoServiceImpl extends BaseMpServiceImpl<PurchaseOrde
194 202
195 203 getBaseMapper().update(updateWrapper);
196 204
  205 + //更新订货单表物料行
  206 + List<UpdatePurchaseOrderLineVo> updatePurchaseOrderLineVoList = vo.getUpdatePurchaseOrderLineVoList();
  207 + if (CollectionUtils.isNotEmpty(updatePurchaseOrderLineVoList)) {
  208 + for (UpdatePurchaseOrderLineVo updatePurchaseOrderLineVo : updatePurchaseOrderLineVoList) {
  209 + purchaseOrderLineService.update(updatePurchaseOrderLineVo);
  210 + }
  211 + }
  212 +
197 213 OpLogUtil.setVariable("id", data.getId());
198 214 OpLogUtil.setExtra(vo);
199 215 }
... ...
... ... @@ -21,4 +21,6 @@ public interface PurchaseOrderInfoMapper extends BaseMapper<PurchaseOrderInfo> {
21 21 * @return
22 22 */
23 23 List<PurchaseOrderInfo> query(@Param("vo") QueryPurchaseOrderInfoVo vo);
  24 +
  25 + PurchaseOrderInfo findById(@Param("id") String id);
24 26 }
... ...
... ... @@ -32,13 +32,13 @@ public class QueryPurchaseOrderInfoVo extends PageVo implements BaseVo, Serializ
32 32 /**
33 33 * 订货开始日期
34 34 */
35   - @ApiModelProperty("登记开始日期")
  35 + @ApiModelProperty("订货开始日期")
36 36 private String orderDateStart;
37 37
38 38 /**
39 39 * 订货结束日期
40 40 */
41   - @ApiModelProperty("登记结束日期")
  41 + @ApiModelProperty("订货结束日期")
42 42 private String orderDateEnd;
43 43
44 44 /**
... ...
... ... @@ -8,6 +8,7 @@ import com.lframework.starter.web.core.components.validation.TypeMismatch;
8 8 import io.swagger.annotations.ApiModelProperty;
9 9 import org.hibernate.validator.constraints.Length;
10 10 import java.io.Serializable;
  11 +import java.util.List;
11 12
12 13 @Data
13 14 public class UpdatePurchaseOrderInfoVo implements BaseVo, Serializable {
... ... @@ -184,4 +185,10 @@ public class UpdatePurchaseOrderInfoVo implements BaseVo, Serializable {
184 185 @ApiModelProperty("客户资信Id")
185 186 private String customerCreditId;
186 187
  188 + /**
  189 + * 订货单表物料行
  190 + */
  191 + @ApiModelProperty("订货单表物料行")
  192 + private List<UpdatePurchaseOrderLineVo> updatePurchaseOrderLineVoList;
  193 +
187 194 }
... ...
... ... @@ -92,11 +92,11 @@
92 92 AND cu.name LIKE CONCAT('%', #{vo.orderingUnitName},'%')
93 93 </if>
94 94 <if test="vo.orderDateStart != null">
95   - AND tb.order_date >= #{vo.orderDate}
  95 + AND tb.order_date >= #{vo.orderDateStart}
96 96 </if>
97 97 <if test="vo.orderDateEnd != null">
98 98 <![CDATA[
99   - AND tb.order_date <= #{vo.orderDate}
  99 + AND tb.order_date <= #{vo.orderDateEnd}
100 100 ]]>
101 101 </if>
102 102 <if test="vo.status != null and vo.status != ''">
... ... @@ -114,4 +114,13 @@
114 114 </where>
115 115 ORDER BY tb.update_time DESC
116 116 </select>
  117 +
  118 + <select id="findById" resultType="com.lframework.xingyun.sc.entity.PurchaseOrderInfo">
  119 + <include refid="PurchaseOrderInfo_sql"/>
  120 + <where>
  121 + <if test="id != null and id != ''">
  122 + AND tb.id = #{id}
  123 + </if>
  124 + </where>
  125 + </select>
117 126 </mapper>
... ...