|
|
@@ -1,5 +1,7 @@
|
|
|
package com.dk.mdm.service.mac;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.dk.common.infrastructure.annotaiton.Pagination;
|
|
|
import com.dk.common.infrastructure.constant.Constant;
|
|
|
@@ -19,6 +21,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.UUID;
|
|
|
|
|
|
@@ -26,71 +29,76 @@ import java.util.UUID;
|
|
|
@Transactional
|
|
|
public class ReceiptService extends BaseService<Receipt> {
|
|
|
|
|
|
- @Override
|
|
|
- public String getPrimaryKey() {
|
|
|
- return "receipt_id";
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public String getPrimaryKey() {
|
|
|
+ return "receipt_id";
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public BaseMapper<Receipt> getRepository() {
|
|
|
- return receiptMapper;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public BaseMapper<Receipt> getRepository() {
|
|
|
+ return receiptMapper;
|
|
|
+ }
|
|
|
|
|
|
- @Autowired
|
|
|
- private ReceiptMapper receiptMapper;
|
|
|
+ @Autowired
|
|
|
+ private ReceiptMapper receiptMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- private CommonService commonService;
|
|
|
+ @Autowired
|
|
|
+ private CommonService commonService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ReceiptConvert receiptConvert;
|
|
|
-
|
|
|
- /**
|
|
|
- * @desc : 条件查询
|
|
|
- * @author : 付斌
|
|
|
- * @date : 2023/1/9 10:40
|
|
|
- */
|
|
|
- @Pagination
|
|
|
- public ResponseResultVO<PageList<ReceiptResponse>> selectByCond(ReceiptQuery receiptQuery) {
|
|
|
- return super.mergeListWithCount(receiptQuery, receiptMapper.selectByCond(receiptQuery),
|
|
|
- receiptMapper.countByCond(receiptQuery));
|
|
|
- }
|
|
|
+ @Autowired
|
|
|
+ private ReceiptConvert receiptConvert;
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc : 条件查询
|
|
|
+ * @author : 付斌
|
|
|
+ * @date : 2023/1/9 10:40
|
|
|
+ */
|
|
|
+ @Pagination
|
|
|
+ public ResponseResultVO<PageList<ReceiptResponse>> selectByCond(ReceiptQuery receiptQuery) {
|
|
|
+ return super.mergeListWithCount(receiptQuery, receiptMapper.selectByCond(receiptQuery),
|
|
|
+ receiptMapper.countByCond(receiptQuery));
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * @desc : 新建方法
|
|
|
- * @author : 付斌
|
|
|
- * @date : 2023/1/9 10:49
|
|
|
- */
|
|
|
- @Transactional(
|
|
|
- rollbackFor = {Exception.class}
|
|
|
- )
|
|
|
- public ResponseResultVO<?> insert(ReceiptVO receiptVO) {
|
|
|
|
|
|
- // 获取单号
|
|
|
- Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSRECEIPT.getName(), false);
|
|
|
- receiptVO.setReceiptId(codeMap.get("outId").toString()).setReceiptNo(codeMap.get("outNote").toString())
|
|
|
- .setReceiptType(Constant.DocumentType.ORDER.getName());
|
|
|
- // 转化实体
|
|
|
- Receipt receipt = receiptConvert.convertToPo(receiptVO);
|
|
|
- // Receipt总单保存
|
|
|
- super.insert(receipt);
|
|
|
+ /**
|
|
|
+ * @desc : 新建方法
|
|
|
+ * @author : 付斌
|
|
|
+ * @date : 2023/1/9 10:49
|
|
|
+ */
|
|
|
+ @Transactional(
|
|
|
+ rollbackFor = {Exception.class}
|
|
|
+ )
|
|
|
+ public ResponseResultVO<?> insert(Map<String, Object> map) {
|
|
|
|
|
|
-
|
|
|
- return ResponseResultUtil.success();
|
|
|
- }
|
|
|
+ List<ReceiptVO> receiptVOList = JSONArray.parseArray(JSON.toJSONString(map.get("itemList"))).toJavaList(ReceiptVO.class);
|
|
|
+ // 明细保存
|
|
|
+ if (receiptVOList != null && receiptVOList.size() > 0) {
|
|
|
+ for (ReceiptVO receiptVO : receiptVOList) {
|
|
|
+ // 获取单号
|
|
|
+ Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSRECEIPT.getName(), false);
|
|
|
+ receiptVO.setReceiptId(codeMap.get("outId").toString()).setReceiptNo(codeMap.get("outNote").toString())
|
|
|
+ .setReceiptType(Constant.DocumentType.ORDER.getName());
|
|
|
+ // 转化实体
|
|
|
+ Receipt receipt = receiptConvert.convertToPo(receiptVO);
|
|
|
+ // Receipt总单保存
|
|
|
+ super.insert(receipt);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * @desc : 编辑方法
|
|
|
- * @author : 付斌
|
|
|
- * @date : 2023/1/9 10:49
|
|
|
- */
|
|
|
- @Transactional(
|
|
|
- rollbackFor = {Exception.class}
|
|
|
- )
|
|
|
- public ResponseResultVO<?> update(ReceiptVO receiptVO) {
|
|
|
- Receipt receipt = receiptConvert.convertToPo(receiptVO);
|
|
|
- return ResponseResultUtil.success(super.update(receipt, new UpdateWrapper<Receipt>().lambda().eq(Receipt::getReceiptId,
|
|
|
- UUID.fromString(receipt.getReceiptId()))));
|
|
|
- }
|
|
|
+ return ResponseResultUtil.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc : 编辑方法
|
|
|
+ * @author : 付斌
|
|
|
+ * @date : 2023/1/9 10:49
|
|
|
+ */
|
|
|
+ @Transactional(
|
|
|
+ rollbackFor = {Exception.class}
|
|
|
+ )
|
|
|
+ public ResponseResultVO<?> update(ReceiptVO receiptVO) {
|
|
|
+ Receipt receipt = receiptConvert.convertToPo(receiptVO);
|
|
|
+ return ResponseResultUtil.success(super.update(receipt, new UpdateWrapper<Receipt>().lambda().eq(Receipt::getReceiptId,
|
|
|
+ UUID.fromString(receipt.getReceiptId()))));
|
|
|
+ }
|
|
|
}
|