From a51ed995ac6e9a8ba63b53aca929aeed15edf8a8 Mon Sep 17 00:00:00 2001
From: Fancy <Fancy.fx@outlook.com>
Date: 星期二, 20 八月 2024 09:05:23 +0800
Subject: [PATCH] order manage
---
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderSv.java | 129 +++++++++++++++++++++++++
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/QueryVo.java | 17 +++
pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderCtrl.java | 116 +++++++++++++++++++++++
3 files changed, 262 insertions(+), 0 deletions(-)
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderCtrl.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderCtrl.java
new file mode 100644
index 0000000..aebb135
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderCtrl.java
@@ -0,0 +1,116 @@
+package com.dy.pmsProduct.order;
+
+import com.dy.common.aop.SsoPowerAop;
+import com.dy.common.webUtil.BaseResponse;
+import com.dy.common.webUtil.BaseResponseUtils;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.aop.Log;
+import com.dy.pmsGlobal.pojoPr.PrAssemblyPlan;
+import com.dy.pmsGlobal.pojoPr.PrOrder;
+import com.dy.pmsProduct.taskPlan.QueryVo;
+import jakarta.validation.Valid;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * 璁㈠崟绠$悊
+ */
+@Slf4j
+@RestController
+@RequestMapping(path="order")
+public class OrderCtrl {
+ private OrderSv sv;
+ @Autowired
+ public void setAssemblySv(OrderSv orderSv) {
+ this.sv = orderSv;
+ }
+ @PostMapping(path="save")
+ @SsoPowerAop(power = "10200001")
+ @Log("淇濆瓨璁㈠崟淇℃伅")
+ public BaseResponse<Boolean> save(@RequestBody @Valid PrOrder order){
+ order.id = null;
+ order.setDeleted(false);
+ int count = sv.save(order);
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * 鏇存柊
+ * @param order
+ * @return
+ */
+ @PostMapping(path="update")
+ @SsoPowerAop(power = "10200001")
+ @Log("淇敼璁㈠崟淇℃伅")
+ public BaseResponse<Boolean> update(@RequestBody @Valid PrOrder order){
+ int count = sv.update(order);
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * 鍒犻櫎璁㈠崟淇℃伅
+ * @param id
+ * @return
+ */
+ @GetMapping(path="delete")
+ @SsoPowerAop(power = "10300001")
+ @Log("鍒犻櫎璁㈠崟淇℃伅")
+ public BaseResponse<Boolean> delete(String id){
+ int count = sv.delete(Long.parseLong(id));
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+ /**
+ * 鏍规嵁ID鏌ヨ
+ * @return
+ */
+ @GetMapping(path="one")
+ @SsoPowerAop(power = "10200000")
+ @Log("鏍规嵁ID鏌ヨ璁㈠崟淇℃伅")
+ public BaseResponse<PrOrder> one(String id){
+ PrOrder plan=sv.selectById(id);
+ return BaseResponseUtils.buildSuccess(plan);
+ }
+
+ /**
+ * 鍒嗛〉鏌ヨ
+ * @param vo
+ * @return
+ */
+ @PostMapping(path="some")
+ @SsoPowerAop(power = "10200000")
+ @Log("鍒嗛〉鏌ヨ璁㈠崟淇℃伅")
+ public BaseResponse<QueryResultVo<List<PrOrder>>> some(@RequestBody QueryVo vo){
+ QueryResultVo<List<PrOrder>> list = sv.selectSome(vo) ;
+ return BaseResponseUtils.buildSuccess(list);
+ }
+
+ @PostMapping(path="updateStatus")
+ @SsoPowerAop(power = "10200001")
+ @Log("鏇存柊浠诲姟璁″垝鐘舵��")
+ public BaseResponse<Boolean> updateStatus(@RequestBody PrAssemblyPlan plan){
+ int count = sv.updateStatus(plan);
+ if (count <= 0) {
+ return BaseResponseUtils.buildFail("鏁版嵁搴撳瓨鍌ㄥけ璐�");
+ } else {
+ return BaseResponseUtils.buildSuccess(true);
+ }
+ }
+
+
+}
\ No newline at end of file
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderSv.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderSv.java
new file mode 100644
index 0000000..24b0909
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/OrderSv.java
@@ -0,0 +1,129 @@
+package com.dy.pmsProduct.order;
+
+import cn.hutool.core.codec.Base64;
+import com.dy.common.webUtil.QueryResultVo;
+import com.dy.pmsGlobal.daoOth.OthFileMapper;
+import com.dy.pmsGlobal.daoPr.*;
+import com.dy.pmsGlobal.dyFile.FileOperate;
+import com.dy.pmsGlobal.pojoPlt.PltProduct;
+import com.dy.pmsGlobal.pojoPr.*;
+import com.dy.pmsGlobal.util.QrCodeUtil;
+import com.dy.pmsGlobal.util.UserUtil;
+import com.dy.pmsProduct.process.QueryVo;
+import com.google.zxing.WriterException;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.dubbo.common.utils.PojoUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class OrderSv {
+ private PrOrderMapper orderDao;
+ private PrOrderItemMapper orderItemDao;
+ private UserUtil userUtil;
+ private FileOperate fileOperate;
+ private OthFileMapper othFileMapper;
+ @Value("${dy.webFile.fmUrl}")
+ private String fmUrl;
+ @Autowired
+ public void setOrderDao(PrOrderMapper orderDao) {
+ this.orderDao = orderDao;
+ }
+
+ @Autowired
+ public void setOrderItemDao(PrOrderItemMapper orderItemDao) {
+ this.orderItemDao = orderItemDao;
+ }
+
+ @Autowired
+ public void setUserUtil(UserUtil userUtil) {
+ this.userUtil = userUtil;
+ }
+
+ @Autowired
+ public void setFileOperate(FileOperate fileOperate) {
+ this.fileOperate = fileOperate;
+ }
+
+ @Autowired
+ public void setOthFileMapper(OthFileMapper othFileMapper) {
+ this.othFileMapper = othFileMapper;
+ }
+
+ @Transactional
+ public int save(PrOrder p) {
+ //鍒ゆ柇浜у搧涓嶈兘閲嶅悕
+ if (orderDao.exists(p.name, p.id)) {
+ throw new RuntimeException("璁㈠崟鍚嶇О涓嶈兘閲嶅");
+ }
+ int count = orderDao.insertSelective(p);
+ saveOrderItems(p);
+ return count;
+ }
+ @Transactional
+ public int update(PrOrder p) {
+ if (orderDao.exists(p.name, p.id)) {
+ throw new RuntimeException("璁㈠崟鍚嶇О涓嶈兘閲嶅");
+ }
+ int count = orderDao.updateByPrimaryKeySelective(p);
+ saveOrderItems(p);
+ return count;
+ }
+ private void saveOrderItems(PrOrder p) {
+ p.items.forEach(param->{
+ param.orderId=p.id;
+ if(param.id !=null){
+ orderItemDao.updateByPrimaryKeySelective(param);
+ }else{
+ param.deleted=false;
+ orderItemDao.insert(param);
+ }
+ });
+ }
+
+ /**
+ * 閫昏緫鍒犻櫎瀹炰綋
+ * @param id 瀹炰綋ID
+ * @return 褰卞搷璁板綍鏁伴噺
+ */
+ @Transactional
+ public int delete(Long id) {
+ return orderDao.deleteLogicById(id);
+ }
+
+ public PrOrder selectById(String proId) {
+ PrOrder pro=orderDao.selectByPrimaryKey(Long.valueOf(proId));
+ return pro;
+ }
+
+ /**
+ * 鑾峰彇璁㈠崟鍒楄〃
+ */
+ public QueryResultVo<List<PrOrder>> selectSome(QueryVo queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰曟�绘暟
+ Long itemTotal = orderDao.selectSomeCount(params);
+
+ QueryResultVo<List<PrOrder>> rsVo = new QueryResultVo<>(queryVo.pageSize, queryVo.pageCurr);
+ //璁$畻鍒嗛〉绛変俊鎭�
+ rsVo.calculateAndSet(itemTotal, params);
+
+ //鏌ヨ绗﹀悎鏉′欢鐨勮褰�
+ rsVo.obj = orderDao.selectSome(params);
+ return rsVo;
+ }
+
+ public List<PrOrder> selectAll(QueryVo queryVo) {
+ Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
+ return orderDao.selectAll(params);
+ }
+}
\ No newline at end of file
diff --git a/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/QueryVo.java b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/QueryVo.java
new file mode 100644
index 0000000..4a775dc
--- /dev/null
+++ b/pms-parent/pms-web-product/src/main/java/com/dy/pmsProduct/order/QueryVo.java
@@ -0,0 +1,17 @@
+package com.dy.pmsProduct.order;
+
+import com.dy.common.webUtil.QueryConditionVo;
+import lombok.*;
+
+@Data
+@EqualsAndHashCode(callSuper = false)
+@ToString(callSuper = true)
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class QueryVo extends QueryConditionVo {
+ public String name;
+ public String director;
+ public String dMobile;
+ public String type;
+}
--
Gitblit v1.8.0