瀏覽代碼

其它支出

fubin 2 年之前
父節點
當前提交
dc91b4ad1d

+ 74 - 4
src/main/java/com/dk/mdm/controller/mac/OtherPayableController.java

@@ -1,17 +1,23 @@
 package com.dk.mdm.controller.mac;
 
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.model.pojo.mac.OtherPayable;
-import com.dk.common.controller.BaseController;
 import com.dk.common.service.BaseService;
-import org.springframework.web.bind.annotation.RequestMapping;
+import com.dk.mdm.model.query.mac.OtherPayableQuery;
+import com.dk.mdm.model.response.mac.OtherPayableResponse;
+import com.dk.mdm.model.vo.mac.OtherPayableVO;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.Api;
 import com.dk.mdm.service.mac.OtherPayableService;
 
+import java.util.Map;
+
 @Api(tags = "其他支出单API接口")
 @RestController
-@RequestMapping("/otherPayable")
+@RequestMapping("/mac/otherPayable")
 public class OtherPayableController{
 
     public BaseService<OtherPayable> getService() {
@@ -21,4 +27,68 @@ public class OtherPayableController{
     @Autowired
     private OtherPayableService otherPayableService;
 
+    /**
+     * @desc : 条件查询
+     * @author : 付斌
+     * @date : 2023/1/9 10:36
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"list_by"})
+    public ResponseResultVO<PageList<OtherPayableResponse>> selectByCond(@RequestBody OtherPayableQuery otherPayableQuery) {
+        return otherPayableService.selectByCond(otherPayableQuery);
+    }
+
+    /**
+     * @desc :查询其它收入明细(明细附件)
+     * @author : 付斌
+     * @date : 2024-02-28 13:24
+     */
+    @PostMapping({"select_other_payable_info_by_id/{id}"})
+    public ResponseResultVO<Map<String, Object>> selectOtherPayableInfoById(@PathVariable String id) {
+        return otherPayableService.selectOtherPayableInfoById(id);
+    }
+
+    /**
+     * @desc : 新建方法
+     * @author : 付斌
+     * @date : 2023/1/9 10:48
+     */
+    @ApiOperation(value = "新建", notes = "新建")
+    @PostMapping({"insert"})
+    public ResponseResultVO<?> insert(@RequestBody OtherPayableVO otherPayableVO) {
+        return otherPayableService.insert(otherPayableVO);
+    }
+
+    /**
+     * @desc : 编辑方法
+     * @author : 付斌
+     * @date : 2023/1/9 10:49
+     */
+    @ApiOperation(value = "编辑", notes = "编辑")
+    @PostMapping({"update"})
+    public ResponseResultVO<?> update(@RequestBody OtherPayableVO otherPayableVO) {
+        return otherPayableService.update(otherPayableVO);
+    }
+
+    /**
+     * @desc :查询其它收入明细(明细附件)
+     * @author : 付斌
+     * @date : 2024-02-28 13:24
+     */
+    @PostMapping({"get_other_payable_for_update/{id}"})
+    public ResponseResultVO<?> getOtherPayableForUpdate(@PathVariable String id) {
+        return otherPayableService.getOtherPayableForUpdate(id);
+    }
+
+    /**
+     * @desc : 作废
+     * @author : 付斌
+     * @date : 2024-03-08 16:36
+     */
+    @ApiOperation(value = "作废", notes = "作废")
+    @PostMapping({"invalid/{id}"})
+    public ResponseResultVO<?> invalid(@PathVariable String id) {
+        return otherPayableService.invalid(id);
+    }
+
 }

+ 22 - 0
src/main/java/com/dk/mdm/infrastructure/convert/mac/OtherPayableConvert.java

@@ -0,0 +1,22 @@
+package com.dk.mdm.infrastructure.convert.mac;
+
+import com.dk.mdm.model.pojo.mac.OtherPayable;
+import com.dk.mdm.model.vo.mac.OtherPayableVO;
+import org.mapstruct.Mapper;
+
+/**
+ * @desc   : OtherPayable转换类
+ * @author : 付斌
+ * @date   : 2024-02-28 10:18
+ */
+@Mapper(componentModel = "spring")
+public interface OtherPayableConvert {
+
+    /**
+     * @desc   : 转换vo为pojo
+     * @author : 付斌
+     * @date   : 2024-02-28 15:26
+     */
+    OtherPayable convertToPo(OtherPayableVO recPayVO);
+
+}

+ 22 - 0
src/main/java/com/dk/mdm/infrastructure/convert/mac/OtherPayableItemConvert.java

@@ -0,0 +1,22 @@
+package com.dk.mdm.infrastructure.convert.mac;
+
+import com.dk.mdm.model.pojo.mac.OtherPayableItem;
+import com.dk.mdm.model.vo.mac.OtherPayableItemVO;
+import org.mapstruct.Mapper;
+
+/**
+ * @desc   : OtherPayableItem转换类
+ * @author : 付斌
+ * @date   : 2024-02-28 10:18
+ */
+@Mapper(componentModel = "spring")
+public interface OtherPayableItemConvert {
+
+    /**
+     * @desc   : 转换vo为pojo
+     * @author : 付斌
+     * @date   : 2024-02-28 15:26
+     */
+    OtherPayableItem convertToPo(OtherPayableItemVO otherPayableItemVO);
+
+}

+ 17 - 1
src/main/java/com/dk/mdm/mapper/mac/OtherPayableItemMapper.java

@@ -2,13 +2,29 @@ package com.dk.mdm.mapper.mac;
 
 import com.dk.mdm.model.pojo.mac.OtherPayableItem;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.query.mac.OtherPayableItemQuery;
+import com.dk.mdm.model.response.mac.OtherPayableItemResponse;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
 *  其他支出明细 Mapper
 */
 @Repository
 public interface OtherPayableItemMapper extends BaseMapper<OtherPayableItem>{
-	
+    /**
+     * @desc : 根据条件进行查询
+     * @author : 付斌
+     * @date : 2024-02-28 10:18
+     */
+    List<OtherPayableItemResponse> selectByCond(OtherPayableItemQuery otherPayableQuery);
+
+    /**
+     * @desc : 根据条件进行查询
+     * @author : 付斌
+     * @date : 2024-02-28 10:18
+     */
+    List<OtherPayableItem> selectByZIdForUpdate(String id);
 }
 

+ 15 - 0
src/main/java/com/dk/mdm/mapper/mac/OtherPayableItemMapper.xml

@@ -94,6 +94,15 @@
         WHERE item_id = #{itemId}::uuid
     </select>
 
+    <!-- 根据主表主键锁定表t_psi_outbound_item的多行数据 -->
+    <select id="selectByZIdForUpdate" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_b.t_mac_other_payable_item
+        WHERE payable_id = #{id}::uuid
+        for update
+    </select>
+
     <!-- 根据主键锁定表t_mac_other_payable_item的一行数据 -->
     <select id="selectByIdForUpdate" resultMap="BaseResultMap">
         SELECT
@@ -140,4 +149,10 @@
             )
         </foreach>
     </insert>
+
+    <delete id="deleteById">
+        DELETE
+        FROM dkic_b.t_mac_other_payable_item
+        WHERE item_id = #{id}::uuid;
+    </delete>
 </mapper>

+ 24 - 1
src/main/java/com/dk/mdm/mapper/mac/OtherPayableMapper.java

@@ -2,13 +2,36 @@ package com.dk.mdm.mapper.mac;
 
 import com.dk.mdm.model.pojo.mac.OtherPayable;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.query.mac.OtherPayableQuery;
+import com.dk.mdm.model.response.mac.OtherPayableResponse;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
 *  其他支出单 Mapper
 */
 @Repository
 public interface OtherPayableMapper extends BaseMapper<OtherPayable>{
-	
+    /**
+     * @desc   : 根据条件进行查询
+     * @author : 付斌
+     * @date   : 2024-02-28 10:18
+     */
+    List<OtherPayableResponse> selectByCond(OtherPayableQuery otherPayableQuery);
+
+    /**
+     * @desc   : 根据条件进行查询(数量)
+     * @author : 付斌
+     * @date   : 2024-02-28 10:19
+     */
+    Long countByCond(OtherPayableQuery otherPayableQuery);
+
+    /**
+     * @desc   : 根据Id进行查询
+     * @author : 付斌
+     * @date   : 2024-03-03 9:25
+     */
+    OtherPayableResponse selectById(String id);
 }
 

+ 8 - 0
src/main/java/com/dk/mdm/model/vo/mac/OtherPayableVO.java

@@ -23,6 +23,7 @@ import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  *  其他支出单
@@ -173,5 +174,12 @@ public class OtherPayableVO extends PageInfo<OtherPayableVO> implements Serializ
     private Integer cpId;
 
 
+    @ApiModelProperty(value = "明细")
+    private List<OtherPayableItemVO> itemList;
+
+    @ApiModelProperty(value = "删除明细")
+    private List<OtherPayableItemVO> deleteItemList;
+
+
     private static final long serialVersionUID = 1L;
 }

+ 177 - 0
src/main/java/com/dk/mdm/service/mac/OtherPayableService.java

@@ -1,13 +1,39 @@
 package com.dk.mdm.service.mac;
 
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.dk.common.exception.BaseBusinessException;
+import com.dk.common.infrastructure.annotaiton.Pagination;
+import com.dk.common.infrastructure.constant.Constant;
+import com.dk.common.infrastructure.enums.ErrorCodeEnum;
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseCodeEnum;
+import com.dk.common.response.ResponseResultUtil;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.mdm.infrastructure.convert.mac.OtherPayableConvert;
+import com.dk.mdm.infrastructure.convert.mac.OtherPayableItemConvert;
+import com.dk.mdm.mapper.mac.OtherPayableItemMapper;
 import com.dk.mdm.model.pojo.mac.OtherPayable;
 import com.dk.mdm.mapper.mac.OtherPayableMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.pojo.mac.OtherPayable;
+import com.dk.mdm.model.pojo.mac.OtherPayableItem;
+import com.dk.mdm.model.query.mac.OtherPayableItemQuery;
+import com.dk.mdm.model.query.mac.OtherPayableQuery;
+import com.dk.mdm.model.response.mac.OtherPayableItemResponse;
+import com.dk.mdm.model.response.mac.OtherPayableResponse;
+import com.dk.mdm.model.vo.mac.OtherPayableItemVO;
+import com.dk.mdm.model.vo.mac.OtherPayableVO;
+import com.dk.mdm.service.common.CommonService;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
 @Service
 @Transactional
 public class OtherPayableService extends BaseService<OtherPayable> {
@@ -25,4 +51,155 @@ public class OtherPayableService extends BaseService<OtherPayable> {
 	@Autowired
 	private OtherPayableMapper otherPayableMapper;
 
+	@Autowired
+	private OtherPayableItemMapper otherPayableItemMapper;
+
+	@Autowired
+	private CommonService commonService;
+
+	@Autowired
+	private AccountService accountService;
+
+	@Autowired
+	private OtherPayableConvert otherPayableConvert;
+
+	@Autowired
+	private OtherPayableItemConvert otherPayableItemConvert;
+
+	/**
+	 * @desc : 条件查询
+	 * @author : 付斌
+	 * @date : 2023/1/9 10:40
+	 */
+	@Pagination
+	public ResponseResultVO<PageList<OtherPayableResponse>> selectByCond(OtherPayableQuery otherPayableQuery) {
+		return super.mergeListWithCount(otherPayableQuery, otherPayableMapper.selectByCond(otherPayableQuery),
+				otherPayableMapper.countByCond(otherPayableQuery));
+	}
+
+	/**
+	 * @desc : 查询明细(货物、收款、附件)
+	 * @author : 付斌
+	 * @date : 2024-02-28 13:25
+	 */
+	@Pagination
+	public ResponseResultVO<Map<String, Object>> selectOtherPayableInfoById(String id) {
+		Map<String, Object> result = new HashMap<>();
+		// 商品明细
+		List<OtherPayableItemResponse> otherPayableItem = otherPayableItemMapper.selectByCond(new OtherPayableItemQuery().setPayableId(id));
+		result.put("otherPayableItem", otherPayableItem);
+
+		// 附件
+		return ResponseResultUtil.success(result);
+	}
+
+	/**
+	 * @desc : 新建方法
+	 * @author : 付斌
+	 * @date : 2023/1/9 10:49
+	 */
+	@Transactional(
+			rollbackFor = {Exception.class}
+	)
+	public ResponseResultVO<?> insert(OtherPayableVO otherPayableVO) {
+
+		// 获取单号
+		Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.ORDER.getName(), false);
+		otherPayableVO.setPayableId(codeMap.get("outId").toString()).setPayableNo(codeMap.get("outNote").toString())
+				.setObjectType(Constant.ObjectType.CUS.getName());
+		// 转化实体
+		OtherPayable otherPayable = otherPayableConvert.convertToPo(otherPayableVO);
+		// 总单保存
+		super.insert(otherPayable);
+
+		// 明细保存
+		if (otherPayableVO.getItemList() != null && otherPayableVO.getItemList().size() > 0) {
+			for (OtherPayableItemVO otherPayableItemVO : otherPayableVO.getItemList()) {
+				OtherPayableItem otherPayableItem = otherPayableItemConvert.convertToPo(otherPayableItemVO);
+				otherPayableItem.setPayableId(otherPayable.getPayableId()).setCpId(otherPayable.getCpId());
+				otherPayableItemMapper.insert(otherPayableItem);
+			}
+		}
+
+		// 应收记账
+		accountService.accPayable(otherPayable.getPayableId(),"t_mac_other_payable");
+		return ResponseResultUtil.success();
+	}
+
+	/**
+	 * @desc : 编辑方法
+	 * @author : 付斌
+	 * @date : 2023/1/9 10:49
+	 */
+	@Transactional(
+			rollbackFor = {Exception.class}
+	)
+	public ResponseResultVO<?> update(OtherPayableVO otherPayableVO) {
+
+		// 先更新收款单总表,否则id又更错了
+		OtherPayable otherPayable = otherPayableConvert.convertToPo(otherPayableVO);
+		super.update(otherPayable, new UpdateWrapper<OtherPayable>().lambda().eq(OtherPayable::getPayableId,
+				UUID.fromString(otherPayable.getPayableId())));
+
+		// 应收反记账
+		accountService.reversePayable(otherPayableVO.getPayableId(),"t_mac_other_payable");
+
+		// 将之前的明细全部删除
+		List<OtherPayableItem> otherPayableItemOriginalList = otherPayableItemMapper.selectByZIdForUpdate(otherPayableVO.getPayableId());
+		for (OtherPayableItem otherPayableItem : otherPayableItemOriginalList) {
+			otherPayableItemMapper.deleteById(otherPayableItem.getItemId());
+		}
+
+		// 明细保存
+		if (otherPayableVO.getItemList() != null && otherPayableVO.getItemList().size() > 0) {
+			for (OtherPayableItemVO otherPayableItemVO : otherPayableVO.getItemList()) {
+				OtherPayableItem otherPayableItem = otherPayableItemConvert.convertToPo(otherPayableItemVO);
+				otherPayableItem.setItemId(null).setPayableId(otherPayableVO.getPayableId()).setCpId(otherPayableVO.getCpId());
+				otherPayableItemMapper.insert(otherPayableItem);
+			}
+		}
+
+		// 应收记账
+		accountService.accPayable(otherPayableVO.getPayableId(),"t_mac_other_payable");
+		return ResponseResultUtil.success();
+	}
+
+	/**
+	 * @desc : 获取信息(编辑用)
+	 * @author : 付斌
+	 * @date : 2024-03-02 17:27
+	 */
+	public ResponseResultVO<?> getOtherPayableForUpdate(String id) {
+		Map<String, Object> dataInfo = new HashMap<>();
+		OtherPayableResponse otherPayableResponse = otherPayableMapper.selectById(id);
+		dataInfo.put("data", otherPayableResponse);
+
+		// 商品明细
+		List<OtherPayableItemResponse> otherPayableItemResponse = otherPayableItemMapper.selectByCond(new OtherPayableItemQuery().setPayableId(id));
+		dataInfo.put("dataItem", otherPayableItemResponse);
+		return ResponseResultUtil.success(dataInfo);
+	}
+
+	/**
+	 * @desc : 作废
+	 * @author : 付斌
+	 * @date : 2024-03-08 16:38
+	 */
+	public ResponseResultVO<?> invalid(String id) {
+		OtherPayable otherPayableForUpdate = otherPayableMapper.selectByIdForUpdate(id);
+		// 并发校验
+		if (!otherPayableForUpdate.getFlgValid()) {
+			throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISFLGVALID_FALSE.getMessage());
+		}
+		// 如果所在月份已结账,则不能作废 todo
+
+		// 应收反记账
+		accountService.reversePayable(id,"t_mac_other_payable");
+
+		// 作废
+		OtherPayable otherPayableUpdate = new OtherPayable();
+		otherPayableUpdate.setFlgValid(false).setPayableId(id);
+		super.updateByUuid(otherPayableUpdate);
+		return ResponseResultUtil.success();
+	}
 }

+ 0 - 3
src/main/java/com/dk/mdm/service/mac/OtherReceivableService.java

@@ -50,9 +50,6 @@ public class OtherReceivableService extends BaseService<OtherReceivable> {
 	private OtherReceivableItemMapper otherReceivableItemMapper;
 
 	@Autowired
-	private OtherReceivableItemService otherReceivableItemService;
-
-	@Autowired
 	private CommonService commonService;
 
 	@Autowired