fubin 2 lat temu
rodzic
commit
4e63b0abbc

+ 51 - 4
src/main/java/com/dk/mdm/controller/mac/ReceiptController.java

@@ -1,17 +1,22 @@
 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.Receipt;
-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.ReceiptQuery;
+import com.dk.mdm.model.response.mac.ReceiptResponse;
+import com.dk.mdm.model.vo.mac.ReceiptVO;
+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.ReceiptService;
 
+
 @Api(tags = "收【退】款单API接口")
 @RestController
-@RequestMapping("/receipt")
+@RequestMapping("/mac/receipt")
 public class ReceiptController{
 
     public BaseService<Receipt> getService() {
@@ -21,4 +26,46 @@ public class ReceiptController{
     @Autowired
     private ReceiptService receiptService;
 
+    /**
+     * @desc : 条件查询
+     * @author : 付斌
+     * @date : 2023/1/9 10:36
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"list_by"})
+    public ResponseResultVO<PageList<ReceiptResponse>> selectByCond(@RequestBody ReceiptQuery receiptQuery) {
+        return receiptService.selectByCond(receiptQuery);
+    }
+
+    /**
+     * @desc : 通过ID查询
+     * @author : 付斌
+     * @date : 2023/1/9 10:41
+     */
+    @PostMapping({"/{id}"})
+    public ResponseResultVO selectById(@PathVariable String id) {
+        return receiptService.selectById(id);
+    }
+
+    /**
+     * @desc : 新建
+     * @author : 付斌
+     * @date : 2023/1/9 10:48
+     */
+    @ApiOperation(value = "新建", notes = "新建")
+    @PostMapping({"insert"})
+    public ResponseResultVO<?> insert(@RequestBody ReceiptVO receiptVO) {
+        return receiptService.insert(receiptVO);
+    }
+
+    /**
+     * @desc : 编辑
+     * @author : 付斌
+     * @date : 2023/1/9 10:49
+     */
+    @ApiOperation(value = "编辑", notes = "编辑")
+    @PostMapping({"update"})
+    public ResponseResultVO<?> update(@RequestBody ReceiptVO receiptVO) {
+        return receiptService.update(receiptVO);
+    }
 }

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

@@ -2,13 +2,36 @@ package com.dk.mdm.mapper.mac;
 
 import com.dk.mdm.model.pojo.mac.Receipt;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.query.mac.ReceiptQuery;
+import com.dk.mdm.model.response.mac.ReceiptResponse;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
 *  收【退】款单 Mapper
 */
 @Repository
 public interface ReceiptMapper extends BaseMapper<Receipt>{
-	
+    /**
+     * @desc   : 根据条件进行查询
+     * @author : 付斌
+     * @date   : 2024-02-28 10:18
+     */
+    List<ReceiptResponse> selectByCond(ReceiptQuery receiptQuery);
+
+    /**
+     * @desc   : 根据条件进行查询(数量)
+     * @author : 付斌
+     * @date   : 2024-02-28 10:19
+     */
+    Long countByCond(ReceiptQuery receiptQuery);
+
+    /**
+     * @desc   : 根据Id进行查询
+     * @author : 付斌
+     * @date   : 2024-03-03 9:25
+     */
+    ReceiptResponse selectById(String id);
 }
 

+ 103 - 51
src/main/java/com/dk/mdm/mapper/mac/ReceiptMapper.xml

@@ -39,86 +39,103 @@
                 <result column="op_db_user" property="opDbUser"/>
     </resultMap>
 
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mac.ReceiptResponse">
+        <id column="receipt_id" property="receiptId"/>
+                <result column="receipt_no" property="receiptNo"/>
+            <result column="receipt_date" property="receiptDate" typeHandler="TimestampTypeHandler"/>
+                <result column="receipt_type" property="receiptType"/>
+                <result column="order_id" property="orderId" typeHandler="UuidTypeHandler"/>
+                <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
+                <result column="org_id" property="orgId" typeHandler="UuidTypeHandler"/>
+                <result column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
+                <result column="receipt_mac" property="receiptMac" typeHandler="UuidTypeHandler"/>
+                <result column="receipt_amt" property="receiptAmt"/>
+                <result column="receivable_id" property="receivableId" typeHandler="UuidTypeHandler"/>
+                <result column="waive_amt" property="waiveAmt"/>
+                <result column="handle_amt" property="handleAmt"/>
+                <result column="residue_amt" property="residueAmt"/>
+                <result column="remarks" property="remarks"/>
+                <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
+                <result column="make_staff" property="makeStaff" typeHandler="UuidTypeHandler"/>
+            <result column="make_time" property="makeTime" typeHandler="TimestampTypeHandler"/>
+                <result column="flg_valid" property="flgValid"/>
+                <result column="cp_id" property="cpId"/>
+            <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
+                <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
+            <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
+                <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
+                <result column="op_app_code" property="opAppCode"/>
+            <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
+                <result column="op_db_user" property="opDbUser"/>
+    </resultMap>
+
     <!-- 通用条件列 -->
     <sql id="Condition">
         <where>
             <if test="receiptNo != null and receiptNo != ''">
-                AND receipt_no = #{receiptNo}
+                AND t.receipt_no LIKE concat('%',my_ex.likequery(#{receiptNo}),'%')
             </if>
             <if test="receiptDate != null">
-                AND receipt_date = #{receiptDate}
-            </if>
-            <if test="receiptType != null and receiptType != ''">
-                AND receipt_type = #{receiptType}
+                AND t.receipt_date = #{receiptDate}
             </if>
             <if test="orderId != null and orderId != ''">
-                AND order_id = #{orderId}
-            </if>
-            <if test="cusId != null and cusId != ''">
-                AND cus_id = #{cusId}
-            </if>
-            <if test="orgId != null and orgId != ''">
-                AND org_id = #{orgId}
-            </if>
-            <if test="staffId != null and staffId != ''">
-                AND staff_id = #{staffId}
-            </if>
-            <if test="receiptMac != null and receiptMac != ''">
-                AND receipt_mac = #{receiptMac}
+                AND t.order_id = #{orderId}
             </if>
             <if test="receiptAmt != null">
-                AND receipt_amt = #{receiptAmt}
+                AND t.receipt_amt = #{receiptAmt}
             </if>
             <if test="receivableId != null and receivableId != ''">
-                AND receivable_id = #{receivableId}
+                AND t.receivable_id = #{receivableId}
             </if>
             <if test="waiveAmt != null">
-                AND waive_amt = #{waiveAmt}
+                AND t.waive_amt = #{waiveAmt}
             </if>
             <if test="handleAmt != null">
-                AND handle_amt = #{handleAmt}
+                AND t.handle_amt = #{handleAmt}
             </if>
             <if test="residueAmt != null">
-                AND residue_amt = #{residueAmt}
+                AND t.residue_amt = #{residueAmt}
             </if>
             <if test="remarks != null and remarks != ''">
-                AND remarks = #{remarks}
+                AND t.remarks = #{remarks}
             </if>
             <if test="annexPaths != null and annexPaths != ''">
-                AND annex_paths = #{annexPaths}
+                AND t.annex_paths = #{annexPaths}
             </if>
             <if test="makeStaff != null and makeStaff != ''">
-                AND make_staff = #{makeStaff}
-            </if>
-            <if test="makeTime != null">
-                AND make_time = #{makeTime}
+                AND t.make_staff = #{makeStaff}
             </if>
             <if test="flgValid != null">
-                AND flg_valid = #{flgValid}
+                AND t.flg_valid = #{flgValid}
             </if>
             <if test="cpId != null">
-                AND cp_id = #{cpId}
+                AND t.cp_id = #{cpId}
+            </if>
+            <if test="cusPhone != null and cusPhone != ''">
+                AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
             </if>
-            <if test="opCreateTime != null">
-                AND op_create_time = #{opCreateTime}
+            <if test="cusName != null and cusName != ''">
+                AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
             </if>
-            <if test="opCreateUserId != null and opCreateUserId != ''">
-                AND op_create_user_id = #{opCreateUserId}
+            <if test="addressFull != null and addressFull != ''">
+                AND tmc.address_full LIKE concat('%',my_ex.likequery(#{addressFull}),'%')
             </if>
-            <if test="opUpdateTime != null">
-                AND op_update_time = #{opUpdateTime}
+            <if test="orgIdList != null and orgIdList.size() > 0">
+                AND t.org_id  =any(#{orgIdList, typeHandler=uuidListTypeHandler})
             </if>
-            <if test="opUpdateUserId != null and opUpdateUserId != ''">
-                AND op_update_user_id = #{opUpdateUserId}
+            <if test="staffIdList != null and staffIdList.size() > 0">
+                AND t.staff_id  =any(#{staffIdList, typeHandler=uuidListTypeHandler})
             </if>
-            <if test="opAppCode != null and opAppCode != ''">
-                AND op_app_code = #{opAppCode}
+            <if test="receiptTypeList != null and receiptTypeList.size() > 0">
+                AND t.receipt_type  =any(#{receiptTypeList, typeHandler=StringListTypeHandler})
             </if>
-            <if test="opTimestamp != null">
-                AND op_timestamp = #{opTimestamp}
+            <if test="receiptMacList != null and receiptMacList.size() > 0">
+                AND t.receipt_mac  =any(#{receiptMacList, typeHandler=uuidListTypeHandler})
             </if>
-            <if test="opDbUser != null and opDbUser != ''">
-                AND op_db_user = #{opDbUser}
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND t.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND t.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
         </where>
     </sql>
@@ -132,11 +149,45 @@
     </sql>
 
     <!-- 查询表t_mac_receipt,(条件查询+分页)列表 -->
-    <select id="selectByCond" resultMap="BaseResultMap">
-        SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_mac_receipt
-        <include refid="Condition"/>
+    <select id="selectByCond" resultMap="BaseResultMapResponse">
+        SELECT t.receipt_id,
+               t.receipt_no,
+               t.receipt_date,
+               t.receipt_type,
+               sys.f_get_name_i18n(tdk1.kind_name_i18n, #{i18n}) as "receiptTypeName",
+               t.order_id,
+               tpo.order_no                                      as "orderNo",
+               t.cus_id,
+               tmc.cus_code                                      as "cusCode",
+               tmc.cus_name                                      as "cusName",
+               tmc.cus_phone                                     as "cusPhone",
+               tmc.address_full                                  as "addressFull",
+               t.org_id,
+               tmo.org_name                                      as "orgName",
+               t.staff_id,
+               tms.staff_name                                    as "staffName",
+               t.receipt_mac,
+               t.receipt_amt,
+               t.receivable_id,
+               t.waive_amt,
+               t.handle_amt,
+               t.residue_amt,
+               t.remarks,
+               t.annex_paths,
+               t.make_staff,
+               makestaff.staff_name                              as "makeStaffName",
+               t.make_time,
+               t.flg_valid,
+               t.cp_id
+        FROM dkic_b.t_mac_receipt as t
+                 left join sys.t_data_kind as tdk1 on tdk1.kind_code = t.receipt_type
+                 left join dkic_b.t_mst_org tmo on tmo.org_id = t.org_id
+                 left join dkic_b.t_mst_staff tms on tms.staff_id = t.staff_id
+                 left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
+                 left join dkic_b.t_mst_staff as makestaff on makestaff.staff_id = t.make_staff
+                 left join dkic_b.t_psi_order as tpo on tpo.order_id = t.order_id
+                <include refid="Condition"/>
+        order by t.op_create_time desc
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
@@ -146,7 +197,8 @@
     <select id="countByCond" resultType="Long">
         SELECT
         count(1)
-        FROM t_mac_receipt
+        FROM t_mac_receipt as t
+                left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
         <include refid="Condition"/>
     </select>
 

+ 30 - 0
src/main/java/com/dk/mdm/model/query/mac/ReceiptQuery.java

@@ -19,7 +19,9 @@ import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  *  收【退】款单
@@ -275,6 +277,34 @@ public class ReceiptQuery extends PageInfo<ReceiptQuery> implements Serializable
     @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
     private String opDbUser;
 
+    @ApiModelProperty(value = "客户电话")
+    private String cusPhone;
+
+    @ApiModelProperty(value = "客户名称")
+    private String cusName;
+
+    @ApiModelProperty(value = "详细地址")
+    private String addressFull;
+
+    @ApiModelProperty(value = "部门List")
+    private List<String> orgIdList;
+
+    @ApiModelProperty(value = "业务员List")
+    private List<String> staffIdList;
+
+    @ApiModelProperty(value = "收款类型List")
+    private List<String> receiptTypeList;
+
+    @ApiModelProperty(value = "资金账户List")
+    private List<String> receiptMacList;
+
+    @ApiModelProperty(value = "制单时间开始")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate makeTimeStart;
+
+    @ApiModelProperty(value = "制单时间结束")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate makeTimeEnd;
 
     /*
      * 相关属性

+ 25 - 0
src/main/java/com/dk/mdm/model/response/mac/ReceiptResponse.java

@@ -275,7 +275,32 @@ public class ReceiptResponse extends PageInfo<ReceiptResponse> implements Serial
     @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
     private String opDbUser;
 
+    @ApiModelProperty(value = "收款类型")
+    private String receiptTypeName;
 
+    @ApiModelProperty(value = "订单单号")
+    private String orderNo;
+
+    @ApiModelProperty(value = "客户编码")
+    private String cusCode;
+
+    @ApiModelProperty(value = "客户名称")
+    private String cusName;
+
+    @ApiModelProperty(value = "客户电话")
+    private String cusPhone;
+
+    @ApiModelProperty(value = "详细地址")
+    private String addressFull;
+
+    @ApiModelProperty(value = "组织名称")
+    private String orgName;
+
+    @ApiModelProperty(value = "员工姓名")
+    private String staffName;
+
+    @ApiModelProperty(value = "制单员")
+    private String makeStaffName;
     /*
      * 相关属性
      * @TableField(exist = false)

+ 75 - 0
src/main/java/com/dk/mdm/service/mac/ReceiptService.java

@@ -1,13 +1,34 @@
 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.ReceiptConvert;
 import com.dk.mdm.model.pojo.mac.Receipt;
 import com.dk.mdm.mapper.mac.ReceiptMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.pojo.mst.Customer;
+import com.dk.mdm.model.query.mac.ReceiptQuery;
+import com.dk.mdm.model.response.mac.ReceiptResponse;
+import com.dk.mdm.model.vo.mac.ReceiptVO;
+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;
+import java.util.stream.Collectors;
+
 @Service
 @Transactional
 public class ReceiptService extends BaseService<Receipt> {
@@ -25,4 +46,58 @@ public class ReceiptService extends BaseService<Receipt> {
 	@Autowired
 	private ReceiptMapper receiptMapper;
 
+	@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));
+	}
+
+
+	/**
+	 * @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.ORDER.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);
+
+		
+		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()))));
+	}
 }

+ 6 - 6
src/main/java/com/dk/mdm/service/sale/OrderService.java

@@ -52,12 +52,6 @@ public class OrderService extends BaseService<Order> {
     private OrderMapper orderMapper;
 
     @Autowired
-    private OrderConvert orderConvert;
-
-    @Autowired
-    private OrderItemConvert orderItemConvert;
-
-    @Autowired
     private OrderItemService orderItemService;
 
     @Autowired
@@ -69,6 +63,12 @@ public class OrderService extends BaseService<Order> {
     @Autowired
     private CustomerMapper customerMapper;
 
+    @Autowired
+    private OrderConvert orderConvert;
+
+    @Autowired
+    private OrderItemConvert orderItemConvert;
+
     /**
      * @desc : 条件查询
      * @author : 付斌