Explorar el Código

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	src/main/java/com/dk/mdm/controller/ivt/InboundController.java
dongke hace 2 años
padre
commit
b4d644313f
Se han modificado 47 ficheros con 1729 adiciones y 1069 borrados
  1. 1 27
      src/main/java/com/dk/mdm/controller/common/CommonController.java
  2. 10 0
      src/main/java/com/dk/mdm/controller/ivt/InboundController.java
  3. 18 0
      src/main/java/com/dk/mdm/controller/ivt/InboundPurchaseController.java
  4. 18 0
      src/main/java/com/dk/mdm/controller/ivt/InboundSaleReturnController.java
  5. 41 0
      src/main/java/com/dk/mdm/controller/mst/CusFollowController.java
  6. 11 4
      src/main/java/com/dk/mdm/controller/mst/CustomerController.java
  7. 24 9
      src/main/java/com/dk/mdm/controller/mst/StaffController.java
  8. 27 0
      src/main/java/com/dk/mdm/feign/CompanyFeign.java
  9. 1 1
      src/main/java/com/dk/mdm/infrastructure/convert/mst/StaffConvert.java
  10. 1 3
      src/main/java/com/dk/mdm/infrastructure/util/AuthUtils.java
  11. 6 34
      src/main/java/com/dk/mdm/mapper/common/CommonMapper.java
  12. 52 37
      src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml
  13. 12 0
      src/main/java/com/dk/mdm/mapper/ivt/IntoReturnItemMapper.java
  14. 35 27
      src/main/java/com/dk/mdm/mapper/ivt/IntoReturnItemMapper.xml
  15. 9 0
      src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.java
  16. 5 5
      src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.xml
  17. 22 0
      src/main/java/com/dk/mdm/mapper/mst/CusFollowMapper.java
  18. 145 12
      src/main/java/com/dk/mdm/mapper/mst/CusFollowMapper.xml
  19. 2 1
      src/main/java/com/dk/mdm/mapper/mst/CusFollowStaffMapper.java
  20. 7 0
      src/main/java/com/dk/mdm/mapper/mst/CusFollowStaffMapper.xml
  21. 10 0
      src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.java
  22. 30 0
      src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.xml
  23. 2 2
      src/main/java/com/dk/mdm/mapper/mst/GoodsBrandMapper.xml
  24. 2 2
      src/main/java/com/dk/mdm/mapper/mst/GoodsCategoryMapper.xml
  25. 2 2
      src/main/java/com/dk/mdm/mapper/mst/GoodsSeriesMapper.xml
  26. 1 1
      src/main/java/com/dk/mdm/mapper/mst/StaffMapper.java
  27. 1 1
      src/main/java/com/dk/mdm/mapper/mst/StaffMapper.xml
  28. 0 2
      src/main/java/com/dk/mdm/mapper/mst/SupplierMapper.java
  29. 2 2
      src/main/java/com/dk/mdm/mapper/mst/UnitMapper.xml
  30. 1 1
      src/main/java/com/dk/mdm/mapper/pur/PurchaseMapper.xml
  31. 29 18
      src/main/java/com/dk/mdm/mapper/sale/OrderItemMapper.xml
  32. 19 18
      src/main/java/com/dk/mdm/model/pojo/ivt/IntoReturnItem.java
  33. 19 18
      src/main/java/com/dk/mdm/model/query/ivt/IntoReturnItemQuery.java
  34. 19 18
      src/main/java/com/dk/mdm/model/response/ivt/IntoReturnItemResponse.java
  35. 13 1
      src/main/java/com/dk/mdm/model/response/mst/CusFollowResponse.java
  36. 0 245
      src/main/java/com/dk/mdm/model/response/mst/StaffResponse.java
  37. 19 18
      src/main/java/com/dk/mdm/model/vo/ivt/IntoReturnItemVO.java
  38. 52 6
      src/main/java/com/dk/mdm/model/vo/mst/CusFollowVO.java
  39. 6 32
      src/main/java/com/dk/mdm/service/common/CommonService.java
  40. 28 11
      src/main/java/com/dk/mdm/service/ivt/InboundOtherService.java
  41. 99 27
      src/main/java/com/dk/mdm/service/ivt/InboundPurchaseService.java
  42. 487 372
      src/main/java/com/dk/mdm/service/ivt/InboundSaleReturnService.java
  43. 93 92
      src/main/java/com/dk/mdm/service/ivt/IntoReturnService.java
  44. 288 6
      src/main/java/com/dk/mdm/service/mst/CusFollowService.java
  45. 44 7
      src/main/java/com/dk/mdm/service/mst/CustomerService.java
  46. 4 1
      src/main/java/com/dk/mdm/service/mst/GoodsBrandService.java
  47. 12 6
      src/main/java/com/dk/mdm/service/mst/StaffService.java

+ 1 - 27
src/main/java/com/dk/mdm/controller/common/CommonController.java

@@ -117,20 +117,6 @@ public class CommonController extends BaseController<Map<String, Object>> {
     }
 
     /**
-     * @desc : 获取产品品牌
-     * @author : 夏常明
-     * @date : 2023/1/10 13:53
-     */
-    @ApiOperation(
-            value = "获取产品品牌",
-            notes = "获取产品品牌"
-    )
-    @PostMapping("get_brand")
-    public ResponseResultVO<List<Map<String, Object>>> getBrand(@RequestBody Map<String, Object> param) {
-        return commonService.getBrand(param);
-    }
-
-    /**
      * @desc : 获取角色
      * @author : 姜宁
      * @date : 2023/1/29 14:26
@@ -193,19 +179,7 @@ public class CommonController extends BaseController<Map<String, Object>> {
     public ResponseResultVO<List<Map<String, Object>>> getSettingKind(@RequestBody Map<String, Object> param) {
         return commonService.getSettingKind(param);
     }
-
-    /**
-     * @desc : 获取组织部门
-     * @author : 姜宁
-     * @date : 2023/2/1 14:12
-     */
-    @ApiOperation(value = "获取组织部门分页查询", notes = "获取组织部门分页查询")
-    @PostMapping({"get_organization_by_page"})
-    public ResponseResultVO<PageList<Map<String, Object>>> getOrganizationByPage(@RequestBody Map<String, Object> param) {
-        return commonService.getOrganizationByPage(param);
-    }
-
-
+    
     /**
      * @desc : 获取数据字典
      * @author : 姜宁

+ 10 - 0
src/main/java/com/dk/mdm/controller/ivt/InboundController.java

@@ -57,6 +57,16 @@ public class InboundController{
 
 
     /**
+     * @desc : 查看来源单据,总单加明细  采购退货用
+     * @author : 于继渤
+     * @date : 2024/3/6 10:36
+     */
+    @ApiOperation(value = "条件查询", notes = "条件查询")
+    @PostMapping({"select_inbound_and_item"})
+    public ResponseResultVO<PageList<InboundResponse>> selectInboundAndItem(@RequestBody InboundQuery inboundQuery) {
+        return inboundService.selectInboundAndItem(inboundQuery);
+    }
+    /**
      * @desc : 新建入库单
      * @author : 王英杰
      * @date : 2024/3/6 10:36

+ 18 - 0
src/main/java/com/dk/mdm/controller/ivt/InboundPurchaseController.java

@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.validation.Valid;
+
 
 @Api(tags = "采购入库单API接口")
 @RestController
@@ -48,6 +50,22 @@ public class InboundPurchaseController {
 
 
     /**
+     * @desc   : 采购入库新建
+     * @date   : 2024/3/7 14:00
+     * @author : 寇珊珊
+     */
+    @ApiOperation(
+            value = "采购入库新建",
+            notes = "采购入库新建"
+    )
+    @PostMapping({"purchase_inbound_insert"})
+    public ResponseResultVO<?> purchaseInboundInsert(@Valid @RequestBody InboundVO inboundVO) {
+        return inheritedPurchaseService.purchaseInboundInsert(inboundVO);
+    }
+
+
+
+    /**
      * @desc   : 采购入库办理
      * @date   : 2024/3/7 15:34
      * @author : 寇珊珊

+ 18 - 0
src/main/java/com/dk/mdm/controller/ivt/InboundSaleReturnController.java

@@ -18,6 +18,8 @@ import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.validation.Valid;
+
 
 @Api(tags = "销售退货入库单API接口")
 @RestController
@@ -45,6 +47,22 @@ public class InboundSaleReturnController {
     }
 
 
+
+    /**
+     * @desc   : 销售退货入库新建
+     * @date   : 2024/3/7 14:00
+     * @author : 寇珊珊
+     */
+    @ApiOperation(
+            value = "销售退货入库新建",
+            notes = "销售退货入库新建"
+    )
+    @PostMapping({"sale_return_inbound_insert"})
+    public ResponseResultVO<?> saleReturnInboundInsert(@Valid @RequestBody InboundVO inboundVO) {
+        return inboundSaleReturnService.saleReturnInboundInsert(inboundVO);
+    }
+
+
     /**
      * @desc   : 销售退货入库办理
      * @date   : 2024/3/7 15:34

+ 41 - 0
src/main/java/com/dk/mdm/controller/mst/CusFollowController.java

@@ -1,14 +1,27 @@
 package com.dk.mdm.controller.mst;
 
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.model.pojo.mst.CusFollow;
 import com.dk.common.controller.BaseController;
 import com.dk.common.service.BaseService;
+import com.dk.mdm.model.query.mst.CusFollowQuery;
+import com.dk.mdm.model.query.mst.CustomerQuery;
+import com.dk.mdm.model.response.mst.CusFollowResponse;
+import com.dk.mdm.model.response.mst.CustomerResponse;
+import com.dk.mdm.model.vo.mst.CusFollowVO;
+import com.dk.mdm.model.vo.mst.CustomerVO;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RestController;
 import io.swagger.annotations.Api;
 import com.dk.mdm.service.mst.CusFollowService;
 
+import java.util.List;
+
 @Api(tags = "客户跟进API接口")
 @RestController
 @RequestMapping("/mst/cusFollow")
@@ -21,4 +34,32 @@ public class CusFollowController{
     @Autowired
     private CusFollowService cusFollowService;
 
+
+    /**
+     * @desc : 条件查询
+     * @author : 于继渤
+     * @date : 2024/2/26 10:36
+     */
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"list_by"})
+    public ResponseResultVO<PageList<CusFollowResponse>> selectByCond(@RequestBody CusFollowQuery customerQuery) {
+        return cusFollowService.selectByCond(customerQuery);
+    }
+
+    /**
+     * @desc : 新建
+     * @author : 于继渤
+     * @date : 2023/1/5 9:39
+     */
+    @ApiOperation( value = "新建", notes = "v" )
+    @PostMapping({"insert"})
+    public ResponseResultVO<?> insert(@RequestBody CusFollowVO cusFollowVO) {
+        return cusFollowService.insert(cusFollowVO);
+    }
+
+    @ApiOperation(value = "分页、关联、条件查询", notes = "分页、关联、条件查询")
+    @PostMapping({"select_by_list"})
+    public ResponseResultVO<List<CusFollowResponse>> selectByList(@RequestBody CusFollowQuery customerQuery) {
+        return cusFollowService.selectByList(customerQuery);
+    }
 }

+ 11 - 4
src/main/java/com/dk/mdm/controller/mst/CustomerController.java

@@ -8,11 +8,8 @@ import com.dk.mdm.model.query.mst.CustomerQuery;
 import com.dk.mdm.model.response.mst.CustomerResponse;
 import com.dk.mdm.model.vo.mst.CustomerVO;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
+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.mst.CustomerService;
 
@@ -62,4 +59,14 @@ public class CustomerController{
         return customerService.update(customerVO);
     }
 
+
+    /**
+     * @desc : 查看
+     * @author : 于继渤
+     * @date : 2024/3/6 10:36
+     */
+    @PostMapping({"/{id}"})
+    public ResponseResultVO<?> selectByIdRespone(@PathVariable String id) {
+        return customerService.selectByIdRespone(id);
+    }
 }

+ 24 - 9
src/main/java/com/dk/mdm/controller/mst/StaffController.java

@@ -1,15 +1,16 @@
 package com.dk.mdm.controller.mst;
 
 import com.dk.common.model.pojo.PageList;
-import com.dk.common.model.vo.core.StaffEntity;
+import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.common.util.ExcelUtils;
-import com.dk.mdm.model.pojo.mst.Staff; 
+import com.dk.mdm.model.pojo.mst.Staff;
 import com.dk.common.service.BaseService;
 import com.dk.mdm.model.query.mst.StaffQuery;
-import com.dk.mdm.model.response.mst.StaffResponse;
+import com.dk.common.model.response.mst.StaffResponse;
 import com.dk.mdm.model.vo.mst.StaffVO;
 import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -22,14 +23,15 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * @desc   : 员工API接口
  * @author : 姜永辉
- * @date   : 2023/1/4 9:25
+ * @desc : 员工API接口
+ * @date : 2023/1/4 9:25
  */
 @Api(tags = "员工API接口")
 @RestController
 @RequestMapping("/mst/staff")
-public class StaffController{
+@Slf4j
+public class StaffController {
 
     public BaseService<Staff> getService() {
         return staffService;
@@ -164,15 +166,28 @@ public class StaffController{
     }
 
     /**
-     * @desc   : 导出模板
+     * @desc : 导出模板
      * @author : 洪旭东
-     * @date   : 2023-08-01 11:44
+     * @date : 2023-08-01 11:44
      */
     @ApiOperation(value = "导出模板", notes = "导出模板")
     @GetMapping("export_template")
-    public void exportTemplate(HttpServletResponse response){
+    public void exportTemplate(HttpServletResponse response) {
         String title = "员工导入模板";
         ExcelUtils.exportExcel(new ArrayList<>(), title, title, StaffVO.class, title + ".xls", response);
     }
 
+
+    /**
+     * @desc : 体验产品-从oauth服务调用的函数
+     * @author : 姜永辉
+     * @date : 2023-11-02 16:27
+     */
+    @PostMapping({"/feign_get_experience"})
+    ResponseResultVO<StaffResponse> getFeignExperience(@RequestBody StaffQuery staffQuery) {
+        ResponseResultVO<PageList<StaffResponse>> pageListResponseResultVO = staffService.selectByCond(staffQuery);
+        log.info("feign_get_experience" + pageListResponseResultVO.toString());
+        return ResponseResultUtil.success(pageListResponseResultVO.getData().getList().get(0));
+    }
+
 }

+ 27 - 0
src/main/java/com/dk/mdm/feign/CompanyFeign.java

@@ -0,0 +1,27 @@
+package com.dk.mdm.feign;
+
+
+import com.dk.common.infrastructure.constant.Constant;
+import com.dk.common.model.response.mst.StaffResponse;
+import com.dk.common.response.ResponseResultVO;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+
+import java.util.Map;
+
+/**
+ * @author : 姜永辉
+ * @desc : OauthServerFeign
+ * @date : 2024-038-10 10:56
+ */
+@FeignClient(name = Constant.OAUTH_PREFIX + Constant.SERVER, path = Constant.COMPANY, contextId = "company")
+public interface CompanyFeign {
+    /**
+     * @desc   : 体验产品
+     * @author : 姜永辉
+     * @date   : 2023-11-02 16:27
+     */
+    @PostMapping({"/feign_update_wx_user_company"})
+    ResponseResultVO<Boolean> updateWxUserCompany(@RequestBody Map<String, Object> collectQuery) ;
+}

+ 1 - 1
src/main/java/com/dk/mdm/infrastructure/convert/mst/StaffConvert.java

@@ -2,7 +2,7 @@ package com.dk.mdm.infrastructure.convert.mst;
 
 import com.dk.common.model.vo.core.StaffEntity;
 import com.dk.mdm.model.pojo.mst.Staff;
-import com.dk.mdm.model.response.mst.StaffResponse;
+import com.dk.common.model.response.mst.StaffResponse;
 import com.dk.mdm.model.vo.mst.StaffVO;
 import org.mapstruct.Mapper;
 

+ 1 - 3
src/main/java/com/dk/mdm/infrastructure/util/AuthUtils.java

@@ -9,9 +9,7 @@ import com.dk.common.util.oauth.AESSecurityUtil;
 import com.dk.common.util.oauth.JwtUtil;
 import com.dk.mdm.infrastructure.convert.mst.StaffConvert;
 import com.dk.mdm.mapper.mst.StaffMapper;
-import com.dk.mdm.model.pojo.mst.Staff;
-import com.dk.mdm.model.response.mst.StaffResponse;
-import com.dk.mdm.service.mst.StaffService;
+import com.dk.common.model.response.mst.StaffResponse;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;

+ 6 - 34
src/main/java/com/dk/mdm/mapper/common/CommonMapper.java

@@ -70,19 +70,12 @@ public interface CommonMapper extends BaseMapper<Map<String, Object>> {
      */
     Long getOrgCountByPage(Map param);
 
-    /**
-     * @desc : 获取产品品牌
-     * @author : 夏常明
-     * @date : 2023/1/10 13:57
-     */
-    List<Map<String, Object>> getBrand(Map param);
-
-    /**
-     * @desc : 获取用户菜单
-     * @author : 周兴
-     * @date : 2023/1/9 14:20
-     */
-    List<Map<String, Object>> getMenuByUser(@Param("appCode") String appCode, @Param("userId") Integer userId);
+//    /**
+//     * @desc : 获取用户菜单
+//     * @author : 周兴
+//     * @date : 2023/1/9 14:20
+//     */
+//    List<Map<String, Object>> getMenuByUser(@Param("appCode") String appCode, @Param("userId") Integer userId);
 
     /**
      * @desc : 获取角色
@@ -126,20 +119,6 @@ public interface CommonMapper extends BaseMapper<Map<String, Object>> {
      */
     List<Map<String, Object>> getSettingKind(Map param);
 
-    /**
-     * @desc : 获取组织部门
-     * @author : 姜宁
-     * @date : 2023/2/1 14:10
-     */
-    List<Map<String, Object>> getOrganizationByPage(Map param);
-
-    /**
-     * @desc : 获取组织部门(数量)
-     * @author : 姜宁
-     * @date : 2023/2/1 14:11
-     */
-    Long getOrganizationCountByPage(Map param);
-
 
     /**
      * @desc : 获取数据字典
@@ -378,13 +357,6 @@ public interface CommonMapper extends BaseMapper<Map<String, Object>> {
      */
     Long getInventoryCountByPage(Map param);
 
-     /**
-     * @desc : 获取账户类别
-     * @author : 王英杰
-     * @date : 2024/3/1 9:21
-     */
-    List<Map<String, Object>> getDictionaryDataByPage(Map param);
-
     List<Map<String, Object>> getSaleChannel(Map param);
     List<Map<String, Object>> getStaff(Map param);
 

+ 52 - 37
src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml

@@ -59,9 +59,48 @@
             dkic_b.f_get_user_menu(#{appCode}, #{userId } ::uuid,#{cpId},#{lang})
     </select>
 
-    <resultMap id="BaseResultMap" type="java.util.Map">
-        <result column="kindTags" property="kindTags" typeHandler="JsonTypeHandler"/>
-    </resultMap>
+    <!--查用户功能权限-->
+    <select id="getUserFunction" resultType="java.util.Map">
+        select appm.menu_uuid                                         AS "menuUuid"
+             , appm.menu_name                                         as name
+             , sys.f_get_name_i18n_lang(appm.menu_name_i18n, #{i18n}) as "menuName"
+             , rr.fun_uuid                                            AS "funUuid"
+             , appm.object_code                                       AS "objectCode"
+             , appm.menu_type                                         AS "menuType"
+        from sys.t_app_menu appm
+                 inner join core.t_user_fun rr
+                            on rr.fun_uuid = appm.fun_uuid
+        where appm.flg_valid
+          and appm.app_code = #{appCode}
+          and appm.menu_type IN (1, 2)
+          and rr.user_id = #{userId};
+    </select>
+
+    <!--查询用于隐藏列信息-->
+    <select id="getUserTableInfo" resultType="java.util.Map">
+        select tuts.code,
+               tuts.table_type AS "tableType",
+               tuts.table_ref  AS "tableRef",
+               tuts.columns
+        from pset.t_user_table_set tuts
+        where tuts.flg_valid
+          and tuts.user_id = #{userId};
+    </select>
+
+    <!--查导航菜单(自定义报表用)-->
+    <select id="getMenuNavigation" resultType="java.util.Map">
+        select appm.menu_uuid AS "menuUuid"
+        ,sys.f_get_name_i18n_lang(appm.menu_name_i18n,#{i18n}) as "menuName"
+        ,appm.parent_uuid AS "parentUuid"
+        from sys.t_app_menu appm
+        where appm.flg_valid
+        <if test="parentUuid">
+            and appm.parent_uuid = #{parentUuid} ::uuid
+        </if>
+        and appm.app_code = 'WEB-MAIN'
+        and appm.menu_type = 0
+    </select>
+
 
     <!-- 获取应用-->
     <select id="getApplication" resultType="java.util.Map">
@@ -86,7 +125,7 @@
     </select>
 
     <!-- 获取数据种类 -->
-    <select id="getDataKind" resultMap="BaseResultMap">
+    <select id="getDataKind" resultType="java.util.Map">
         select kind_code AS "kindCode",
         sys.f_get_name_i18n(kind_name_i18n,#{i18n}) as "kindName",
         sys.f_get_name_i18n(kind_desc,#{i18n}) as "gradeKindDesc",
@@ -161,39 +200,6 @@
         </if>
     </select>
 
-    <!-- 获取用户菜单-->
-    <select id="getMenuByUser" resultType="java.util.Map">
-        select menu_uuid      AS "menuUuid",
-        name           AS "name",
-        menu_name      AS "menuName",
-        parent_uuid    AS "parentUuid",
-        menu_type      AS "menuType",
-        flg_menu       AS "flgMenu",
-        flg_right      AS "flgRight",
-        object_code    AS "objectCode",
-        object_paths   AS "objectPaths",
-        object_icon    AS "icon",
-        parent_path    AS "parentPath",
-        menu_tags      AS "menuTags",
-        level_code     AS "levelCode",
-        flg_fast       AS "flgFast",
-        fast_image     AS "fastImage",
-        fast_path      AS "fastPath",
-        ex_menu_uuid   AS "exMenuUuid",
-        flg_same_route AS "flgSameRoute",
-        flg_choose_id  AS "flgChooseId",
-        #{appCode}     AS "appCode",
-        menu_uuid      AS "id",
-        parent_uuid    AS "parentId"
-        from
-        <if test="appCode=='WEB-TOUCH'">
-            core.f_get_user_menu_touch(#{appCode}, #{userId})
-        </if>
-        <if test="appCode!='WEB-TOUCH'">
-            core.f_get_user_menu(#{appCode}, #{userId})
-        </if>
-    </select>
-
     <!-- 获取角色 -->
     <select id="getRole" resultType="java.util.Map">
         select role_Id    AS "roleId",
@@ -280,6 +286,15 @@
         order by dd.display_no
     </select>
 
+    <!-- 获取数据字典项目 -->
+    <select id="getDictionaryItemData" resultType="java.util.Map">
+        SELECT stdi.dict_code                                         AS "dictCode",
+               sys.f_get_name_i18n_lang(stdi.dict_name_i18n, 'zh_CN') AS "dictName"
+        FROM sys.t_dictionary_item stdi
+        WHERE stdi.flg_valid
+          AND stdi.level_no NOT IN ('1')
+    </select>
+
     <!-- 获取数据类型 -->
     <select id="getValueKind" resultType="java.util.Map">
         select tvk.kind_code AS "kindCode",

+ 12 - 0
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnItemMapper.java

@@ -4,6 +4,8 @@ import com.dk.mdm.model.pojo.ivt.IntoReturnItem;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.ivt.IntoReturnItemQuery;
 import com.dk.mdm.model.response.ivt.IntoReturnItemResponse;
+import com.dk.mdm.model.response.pur.PurchaseResponse;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -25,5 +27,15 @@ public interface IntoReturnItemMapper extends BaseMapper<IntoReturnItem>{
      * @date : 2024/2/26 10:36
      */
     Long countByCond(IntoReturnItemQuery intoReturnItemQuery);
+
+
+    /**
+     * @desc   : 根据id查询
+     * @date   : 2024/3/11 14:59
+     * @author : 寇珊珊
+     */
+    IntoReturnItemResponse selectById(@Param("itemId") String itemId);
+    
+    
 }
 

+ 35 - 27
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnItemMapper.xml

@@ -5,17 +5,22 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        item_id, return_id, into_id, into_item_id, pur_id, pur_item_id, item_index, sku_id, item_qty, price_std, amt_std, price_return, item_amt, non_std_code, into_status, intoing_qty, intoing_amt, into_qty, into_amt, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
+        item_id, return_id, into_id, into_item_id, pur_id, pur_item_id, item_index,
+               sku_id, item_qty, price_std, amt_std, price_return, item_amt, non_std_code,
+               out_status, outoing_qty, outoing_amt, out_qty, out_amt, remarks, flg_valid,
+               cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
     </sql>
 
 
     <sql id="Base_Column_List_Join">
         tpiri.item_id, tpiri.return_id, tpiri.into_id, tpiri.into_item_id, tpiri.pur_id, tpiri.pur_item_id, tpiri.item_index, tpiri.sku_id, tpiri.item_qty,
                      tpiri.price_std,tpiri.amt_std, tpiri.price_return,
-               tpiri.item_amt, tpiri.non_std_code, tpiri.into_status, tpiri.intoing_qty, tpiri.intoing_amt, tpiri.into_qty, tpiri.into_amt,
+               tpiri.item_amt, tpiri.non_std_code, tpiri.out_status, tpiri.outoing_qty, tpiri.outoing_amt, tpiri.out_qty, tpiri.out_amt,
                      tpiri.remarks, tpiri.flg_valid, tpiri.cp_id
     </sql>
 
+
+
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.ivt.IntoReturnItem">
         <id column="item_id" property="itemId"/>
@@ -32,11 +37,12 @@
                 <result column="price_return" property="priceReturn"/>
                 <result column="item_amt" property="itemAmt"/>
                 <result column="non_std_code" property="nonStdCode"/>
-                <result column="into_status" property="intoStatus"/>
-                <result column="intoing_qty" property="intoingQty"/>
-                <result column="intoing_amt" property="intoingAmt"/>
-                <result column="into_qty" property="intoQty"/>
-                <result column="into_amt" property="intoAmt"/>
+                <result column="out_status" property="outStatus"/>
+                <result column="outoing_qty" property="outingQty"/>
+                <result column="outoing_amt" property="outingAmt"/>
+                <result column="out_qty" property="outQty"/>
+                <result column="out_amt" property="outAmt"/>
+
                 <result column="remarks" property="remarks"/>
                 <result column="flg_valid" property="flgValid"/>
                 <result column="cp_id" property="cpId"/>
@@ -64,11 +70,11 @@
         <result column="price_return" property="priceReturn"/>
         <result column="item_amt" property="itemAmt"/>
         <result column="non_std_code" property="nonStdCode"/>
-        <result column="into_status" property="intoStatus"/>
-        <result column="intoing_qty" property="intoingQty"/>
-        <result column="intoing_amt" property="intoingAmt"/>
-        <result column="into_qty" property="intoQty"/>
-        <result column="into_amt" property="intoAmt"/>
+        <result column="out_status" property="outStatus"/>
+        <result column="outoing_qty" property="outingQty"/>
+        <result column="outoing_amt" property="outingAmt"/>
+        <result column="out_qty" property="outQty"/>
+        <result column="out_amt" property="outAmt"/>
         <result column="remarks" property="remarks"/>
         <result column="flg_valid" property="flgValid"/>
         <result column="cp_id" property="cpId"/>
@@ -272,11 +278,11 @@
     </select>
 
     <!-- 根据主键查询表t_psi_into_return_item的一行数据 -->
-    <select id="selectById" resultMap="BaseResultMap">
+    <select id="selectById" resultMap="BaseResultMapResponse">
         SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_psi_into_return_item
-        WHERE item_id = #{itemId}::uuid
+        <include refid="Base_Column_List_Join"/>
+        FROM t_psi_into_return_item tpiri
+        WHERE tpiri.item_id = #{itemId}::uuid
     </select>
 
     <!-- 根据主键锁定表t_psi_into_return_item的一行数据 -->
@@ -284,7 +290,7 @@
         SELECT
         <include refid="Base_Column_List"/>
         FROM t_psi_into_return_item
-        WHERE item_id = #{itemId}
+        WHERE item_id = #{id}
         for update
     </select>
 
@@ -314,11 +320,12 @@
             price_return,
             item_amt,
             non_std_code,
-            into_status,
-            intoing_qty,
-            intoing_amt,
-            into_qty,
-            into_amt,
+            out_status,
+            outoing_qty,
+            outoing_amt,
+            out_qty,
+            out_amt,
+
             remarks,
             cp_id,
             op_app_code,
@@ -341,11 +348,12 @@
                 #{item.priceReturn},
                 #{item.itemAmt},
                 #{item.nonStdCode},
-                #{item.intoStatus},
-                #{item.intoingQty},
-                #{item.intoingAmt},
-                #{item.intoQty},
-                #{item.intoAmt},
+                #{item.outStatus},
+                #{item.outingQty},
+                #{item.outingAmt},
+                #{item.outQty},
+                #{item.outAmt},
+
                 #{item.remarks},
                 #{item.cpId},
                 #{item.opAppCode},

+ 9 - 0
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.java

@@ -4,8 +4,10 @@ import com.dk.mdm.model.pojo.ivt.IntoReturn;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.ivt.IntoReturnQuery;
 import com.dk.mdm.model.query.pur.PurchaseQuery;
+import com.dk.mdm.model.response.ivt.IntoReturnItemResponse;
 import com.dk.mdm.model.response.ivt.IntoReturnResponse;
 import com.dk.mdm.model.response.pur.PurchaseResponse;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -32,5 +34,12 @@ public interface IntoReturnMapper extends BaseMapper<IntoReturn>{
 
     List<IntoReturn> selectReturnList(List<String> intoReturnIdList);
     IntoReturn selectReturnByRighting(String returnId);
+
+    /**
+     * @desc   : 根据id查询
+     * @date   : 2024/3/11 14:59
+     * @author : 寇珊珊
+     */
+    IntoReturnResponse selectById(@Param("returnId") String returnId);
 }
 

+ 5 - 5
src/main/java/com/dk/mdm/mapper/ivt/IntoReturnMapper.xml

@@ -380,11 +380,11 @@
     </select>
 
     <!-- 根据主键查询表t_psi_into_return的一行数据 -->
-    <select id="selectById" resultMap="BaseResultMap">
+    <select id="selectById" resultMap="BaseResultMapResponse">
         SELECT
-        <include refid="Base_Column_List"/>
-        FROM dkic_b.t_psi_into_return
-        WHERE return_id = #{returnId}::uuid
+        <include refid="Base_Column_List_Response"/>
+        FROM dkic_b.t_psi_into_return tpir
+        WHERE tpir.return_id = #{returnId}::uuid
     </select>
 
     <!-- 根据主键锁定表t_psi_into_return的一行数据 -->
@@ -392,7 +392,7 @@
         SELECT
         <include refid="Base_Column_List"/>
         FROM dkic_b.t_psi_into_return
-        WHERE return_id = #{returnId}
+        WHERE return_id = #{id}
         for update
     </select>
 

+ 22 - 0
src/main/java/com/dk/mdm/mapper/mst/CusFollowMapper.java

@@ -2,13 +2,35 @@ package com.dk.mdm.mapper.mst;
 
 import com.dk.mdm.model.pojo.mst.CusFollow;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.query.mst.CusFollowQuery;
+import com.dk.mdm.model.query.mst.CustomerQuery;
+import com.dk.mdm.model.response.mst.CusFollowResponse;
+import com.dk.mdm.model.response.mst.CustomerResponse;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 /**
 *  客户跟进 Mapper
 */
 @Repository
 public interface CusFollowMapper extends BaseMapper<CusFollow>{
+
+
+    /**
+     * @desc   : 根据条件进行查询
+     * @author : 于继渤
+     * @date : 2024/2/26 10:36
+     */
+    List<CusFollowResponse> selectByCond(CusFollowQuery cusFollowQuery);
+    List<CusFollowResponse> selectByList(CusFollowQuery cusFollowQuery);
+
+    /**
+     * @desc   : 根据条件进行查询(数量)
+     * @author : 于继渤
+     * @date : 2024/2/26 10:36
+     */
+    Long countByCond(CusFollowQuery cusFollowQuery);
 	
 }
 

+ 145 - 12
src/main/java/com/dk/mdm/mapper/mst/CusFollowMapper.xml

@@ -7,7 +7,12 @@
     <sql id="Base_Column_List">
         follow_id, cus_id, follow_status, follow_type, follow_org, follow_staff, follow_time, follow_data, follow_time_len, stay_time_len, intention, invite_result, invite_time, design_staff, next_follow_plan, next_follow_time, annex_paths, measure_status, remarks, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
     </sql>
-
+    <sql id="Base_Column_List_Join">
+        tccf.follow_id, tccf.cus_id, tccf.follow_status, tccf.follow_type, tccf.follow_org, tccf.follow_staff, tccf.follow_time, tccf.follow_data,
+                 tccf.follow_time_len, tccf.stay_time_len, tccf.intention, tccf.invite_result, tccf.invite_time, tccf.design_staff,
+                 tccf.next_follow_plan, tccf.next_follow_time,tccf.annex_paths, tccf.measure_status, tccf.remarks, tccf.flg_valid,
+                 tccf.cp_id
+    </sql>
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.CusFollow">
         <id column="follow_id" property="followId"/>
@@ -39,9 +44,42 @@
             <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
                 <result column="op_db_user" property="opDbUser"/>
     </resultMap>
+    <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mst.CusFollowResponse">
+        <id column="follow_id" property="followId"/>
+        <result column="cus_id" property="cusId" typeHandler="UuidTypeHandler"/>
+        <result column="follow_status" property="followStatus"/>
+        <result column="follow_type" property="followType"/>
+        <result column="follow_org" property="followOrg" typeHandler="UuidTypeHandler"/>
+        <result column="follow_staff" property="followStaff" typeHandler="UuidTypeHandler"/>
+        <result column="follow_time" property="followTime" typeHandler="TimestampTypeHandler"/>
+        <result column="follow_data" property="followData"/>
+        <result column="follow_time_len" property="followTimeLen"/>
+        <result column="stay_time_len" property="stayTimeLen"/>
+        <result column="intention" property="intention"/>
+        <result column="invite_result" property="inviteResult"/>
+        <result column="invite_time" property="inviteTime" typeHandler="TimestampTypeHandler"/>
+        <result column="design_staff" property="designStaff" typeHandler="UuidTypeHandler"/>
+        <result column="next_follow_plan" property="nextFollowPlan"/>
+        <result column="next_follow_time" property="nextFollowTime" typeHandler="TimestampTypeHandler"/>
+        <result column="annex_paths" property="annexPaths" typeHandler="JsonTypeHandler"/>
+        <result column="measure_status" property="measureStatus"/>
+        <result column="remarks" property="remarks"/>
+        <result column="flg_valid" property="flgValid"/>
+        <result column="cp_id" property="cpId"/>
+        <result column="cusName" property="cusName"/>
+        <result column="orgName" property="orgName"/>
+        <result column="staffName" property="staffName"/>
+        <result column="cusPhone" property="cusPhone"/>
+        <result column="addressFull" property="addressFull"/>
+        <result column="follow_count" property="followCount"/>
+        <result column="follow_staff_name" property="followStaffName"/>
+        <result column="create_time" property="createTime"  typeHandler="TimestampTypeHandler"/>
+
+
+    </resultMap>
 
     <!-- 通用条件列 -->
-    <sql id="Condition">
+      <sql id="Condition">
         <where>
             <if test="cusId != null and cusId != ''">
                 AND cus_id = #{cusId}
@@ -127,6 +165,72 @@
         </where>
     </sql>
 
+    <sql id="Condition_Join">
+        <where>
+            <if test="cusId != null and cusId != ''">
+                AND tccf.cus_id = #{cusId}::uuid
+            </if>
+            <if test="followStatus != null and followStatus != ''">
+                AND tccf.follow_status = #{followStatus}
+            </if>
+            <if test="followType != null and followType != ''">
+                AND tccf.follow_type = #{followType}
+            </if>
+            <if test="followOrg != null and followOrg != ''">
+                AND tccf.follow_org = #{followOrg}
+            </if>
+            <if test="followStaff != null and followStaff != ''">
+                AND tccf.follow_staff = #{followStaff}
+            </if>
+            <if test="followTime != null">
+                AND tccf.follow_time = #{followTime}
+            </if>
+            <if test="followData != null and followData != ''">
+                AND tccf.follow_data = #{followData}
+            </if>
+            <if test="followTimeLen != null">
+                AND tccf.follow_time_len = #{followTimeLen}
+            </if>
+            <if test="stayTimeLen != null and stayTimeLen != ''">
+                AND tccf.stay_time_len = #{stayTimeLen}
+            </if>
+            <if test="intention != null and intention != ''">
+                AND tccf.intention = #{intention}
+            </if>
+            <if test="inviteResult != null and inviteResult != ''">
+                AND tccf.invite_result = #{inviteResult}
+            </if>
+            <if test="inviteTime != null">
+                AND tccf.invite_time = #{inviteTime}
+            </if>
+            <if test="designStaff != null and designStaff != ''">
+                AND tccf.design_staff = #{designStaff}
+            </if>
+            <if test="nextFollowPlan != null and nextFollowPlan != ''">
+                AND tccf.next_follow_plan = #{nextFollowPlan}
+            </if>
+            <if test="nextFollowTime != null">
+                AND tccf.next_follow_time = #{nextFollowTime}
+            </if>
+            <if test="annexPaths != null and annexPaths != ''">
+                AND tccf.annex_paths = #{annexPaths}
+            </if>
+            <if test="measureStatus != null and measureStatus != ''">
+                AND tccf.measure_status = #{measureStatus}
+            </if>
+            <if test="remarks != null and remarks != ''">
+                AND tccf.remarks = #{remarks}
+            </if>
+            <if test="flgValid != null">
+                AND tccf.flg_valid = #{flgValid}
+            </if>
+            <if test="cpId != null">
+                AND tccf.cp_id = #{cpId}
+            </if>
+
+        </where>
+    </sql>
+
     <sql id="idsForeach">
         <!-- 根据主键followId批量操作 -->
         WHERE follow_id in
@@ -136,29 +240,58 @@
     </sql>
 
     <!-- 查询表t_crm_cus_follow,(条件查询+分页)列表 -->
-    <select id="selectByCond" resultMap="BaseResultMap">
+    <select id="selectByCond" resultMap="BaseResultMapResponse">
         SELECT
-        <include refid="Base_Column_List"/>
-        FROM t_crm_cus_follow
-        <include refid="Condition"/>
+        <include refid="Base_Column_List_Join"/>,
+        tmc.cus_name AS "cusName",
+        tmc.cus_phone AS "cusPhone",
+        tmc.address_full AS "addressFull",
+        tmo.org_name  AS  "orgName",
+        tms.staff_name  AS  "staffName",
+        tmc.follow_count AS follow_count
+        FROM dkic_b.t_crm_cus_follow tccf
+        LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf.cus_id
+        LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tccf.follow_org
+        LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tccf.follow_staff
+        <include refid="Condition_Join"/>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
     </select>
 
+
+    <select id="selectByList" resultMap="BaseResultMapResponse">
+        SELECT
+        <include refid="Base_Column_List_Join"/>,
+        tmc.cus_name AS "cusName",
+        tmc.cus_phone AS "cusPhone",
+        tmc.address_full AS "addressFull",
+        tmo.org_name  AS  "orgName",
+        tms.staff_name  AS  "staffName",
+        tmc.follow_count AS follow_count,
+        tms.staff_name AS follow_staff_name,
+        tccf.op_create_time AS create_time
+        FROM dkic_b.t_crm_cus_follow tccf
+        LEFT JOIN dkic_b.t_mst_customer tmc ON tmc.cus_id = tccf.cus_id
+        LEFT JOIN dkic_b.t_mst_org tmo on tmo.org_id = tccf.follow_org
+        LEFT JOIN dkic_b.t_mst_staff tms on tms.staff_id = tccf.follow_staff
+        <include refid="Condition_Join"/>
+
+    </select>
+
     <!-- 查询表t_crm_cus_follow,(条件查询)个数 -->
     <select id="countByCond" resultType="Long">
         SELECT
         count(1)
-        FROM t_crm_cus_follow
-        <include refid="Condition"/>
+        FROM dkic_b.t_crm_cus_follow tccf
+        <include refid="Condition_Join"/>
     </select>
 
     <!-- 根据主键查询表t_crm_cus_follow的一行数据 -->
     <select id="selectById" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM t_crm_cus_follow
+        FROM dkic_b.t_crm_cus_follow
         WHERE follow_id = #{followId}::uuid
     </select>
 
@@ -166,7 +299,7 @@
     <select id="selectByIdForUpdate" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM t_crm_cus_follow
+        FROM dkic_b.t_crm_cus_follow
         WHERE follow_id = #{followId}
         for update
     </select>
@@ -175,13 +308,13 @@
     <select id="selectByIdsForUpdate" resultMap="BaseResultMap">
         SELECT
         <include refid="Base_Column_List"/>
-        FROM t_crm_cus_follow
+        FROM dkic_b.t_crm_cus_follow
         <include refid="idsForeach"/>
         for update
     </select>
 
     <insert id="insertBatch">
-        insert into t_crm_cus_follow
+        insert into dkic_b.t_crm_cus_follow
         (
         <trim suffixOverrides=",">
             cus_id,

+ 2 - 1
src/main/java/com/dk/mdm/mapper/mst/CusFollowStaffMapper.java

@@ -2,6 +2,7 @@ package com.dk.mdm.mapper.mst;
 
 import com.dk.mdm.model.pojo.mst.CusFollowStaff;
 import com.dk.common.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 /**
@@ -9,6 +10,6 @@ import org.springframework.stereotype.Repository;
 */
 @Repository
 public interface CusFollowStaffMapper extends BaseMapper<CusFollowStaff>{
-	
+    CusFollowStaff selectByCusFollowStaffId(@Param("cusId") String cusId, @Param("followStaff") String followStaff);
 }
 

+ 7 - 0
src/main/java/com/dk/mdm/mapper/mst/CusFollowStaffMapper.xml

@@ -122,4 +122,11 @@
             )
         </foreach>
     </insert>
+
+    <select id="selectByCusFollowStaffId" resultMap="BaseResultMap">
+        SELECT
+        <include refid="Base_Column_List"/>
+        FROM dkic_b.t_crm_cus_follow_staff
+        where cus_id = #{cusId}::uuid and follow_staff = #{followStaff}::uuid
+    </select>
 </mapper>

+ 10 - 0
src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.java

@@ -4,6 +4,7 @@ import com.dk.mdm.model.pojo.mst.Customer;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.mst.CustomerQuery;
 import com.dk.mdm.model.response.mst.CustomerResponse;
+import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 
 import java.util.List;
@@ -26,5 +27,14 @@ public interface CustomerMapper extends BaseMapper<Customer>{
      * @date : 2024/2/26 10:36
      */
     Long countByCond(CustomerQuery customerQuery);
+
+
+    /**
+     * @desc : 查询跟进人
+     * @author : 于继渤
+     * @date : 2022-05-26 14:05
+     */
+    Object selectFollowStaffs(@Param("cusId") String cusId);
+    CustomerResponse selectByIdRespone(@Param("cusId") String cusId);
 }
 

+ 30 - 0
src/main/java/com/dk/mdm/mapper/mst/CustomerMapper.xml

@@ -226,6 +226,7 @@
         SELECT
         count(1)
         FROM dkic_b.t_mst_customer tmc
+
         <include refid="Condition"/>
     </select>
 
@@ -237,6 +238,27 @@
         WHERE cus_id = #{cusId}::uuid
     </select>
 
+
+
+    <select id="selectByIdRespone" resultMap="BaseResultMapResponse">
+        SELECT
+        <include refid="Base_Column_List_Response"/>,
+        tmd.data_value  AS  "cusFromName",
+        tmsc.channel_name  AS  "channelName",
+        tmo.org_name  AS  "orgName",
+        tms.staff_name  AS  "staffName",
+        tms2.staff_name  AS  "reportStaffName",
+        tdk.kind_name_i18n  ->> 'zh_CN' AS "saleStatusName"
+        FROM dkic_b.t_mst_customer tmc
+        LEFT JOIN  dkic_b.t_mst_dictionary_data tmd  on tmd.data_id =  tmc.cus_from
+        LEFT JOIN  dkic_b.t_mst_sale_channel tmsc  on tmsc.channel_id =  tmc.channel_id
+        LEFT JOIN  dkic_b.t_mst_org tmo  on tmo.org_id =  tmc.org_id
+        LEFT JOIN  dkic_b.t_mst_staff tms  on tms.staff_id =  tmc.staff_id
+        LEFT JOIN  dkic_b.t_mst_staff tms2  on tms2.staff_id =  tmc.report_staff
+        LEFT JOIN  sys.t_data_kind tdk  on tdk.kind_code =  tmc.sale_status
+        WHERE cus_id = #{cusId}::uuid
+    </select>
+
     <!-- 根据主键锁定表t_mst_customer的一行数据 -->
     <select id="selectByIdForUpdate" resultMap="BaseResultMap">
         SELECT
@@ -321,4 +343,12 @@
             )
         </foreach>
     </insert>
+
+    <!--    查询跟进人-->
+    <select id="selectFollowStaffs" resultType="Object">
+        SELECT follow_staffs
+        from dkic_b.t_mst_customer
+        WHERE cus_id = #{cusId}::uuid
+    </select>
+
 </mapper>

+ 2 - 2
src/main/java/com/dk/mdm/mapper/mst/GoodsBrandMapper.xml

@@ -51,10 +51,10 @@
     <sql id="Condition">
         <where>
             <if test="brandCode != null and brandCode != ''">
-                AND tmgb.brand_code = #{brandCode}
+                AND tmgb.brand_code LIKE concat('%',my_ex.likequery(#{brandCode}),'%')
             </if>
             <if test="brandName != null and brandName != ''">
-                AND tmgb.brand_name = #{brandName}
+                AND tmgb.brand_name LIKE concat('%',my_ex.likequery(#{brandName}),'%')
             </if>
             <if test="shortName != null and shortName != ''">
                 AND tmgb.short_name = #{shortName}

+ 2 - 2
src/main/java/com/dk/mdm/mapper/mst/GoodsCategoryMapper.xml

@@ -66,10 +66,10 @@
     <sql id="Condition">
         <where>
             <if test="catCode != null and catCode != ''">
-                AND tmgc.cat_code = #{catCode}
+                AND tmgc.cat_code LIKE concat('%',my_ex.likequery(#{catCode}),'%')
             </if>
             <if test="catName != null and catName != ''">
-                AND tmgc.cat_name = #{catName}
+                AND tmgc.cat_name LIKE concat('%',my_ex.likequery(#{catName}),'%')
             </if>
             <if test="parentId != null and parentId != ''">
                 AND tmgc.parent_id = #{parentId}

+ 2 - 2
src/main/java/com/dk/mdm/mapper/mst/GoodsSeriesMapper.xml

@@ -31,10 +31,10 @@
     <sql id="Condition">
         <where>
             <if test="seriesCode != null and seriesCode != ''">
-                AND series_code = #{seriesCode}
+                AND series_code LIKE concat('%',my_ex.likequery(#{seriesCode}),'%')
             </if>
             <if test="seriesName != null and seriesName != ''">
-                AND series_name = #{seriesName}
+                AND series_name LIKE concat('%',my_ex.likequery(#{seriesName}),'%')
             </if>
             <if test="displayNo != null">
                 AND display_no = #{displayNo}

+ 1 - 1
src/main/java/com/dk/mdm/mapper/mst/StaffMapper.java

@@ -3,7 +3,7 @@ package com.dk.mdm.mapper.mst;
 import com.dk.mdm.model.pojo.mst.Staff;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.mst.StaffQuery;
-import com.dk.mdm.model.response.mst.StaffResponse;
+import com.dk.common.model.response.mst.StaffResponse;
 import org.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Repository;
 

+ 1 - 1
src/main/java/com/dk/mdm/mapper/mst/StaffMapper.xml

@@ -12,7 +12,7 @@
     </sql>
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="BaseResultMap" type="com.dk.mdm.model.response.mst.StaffResponse">
+    <resultMap id="BaseResultMap" type="com.dk.common.model.response.mst.StaffResponse">
         <id column="staff_id" property="staffId" typeHandler="UuidTypeHandler"/>
         <result column="staff_code" property="staffCode"/>
         <result column="staff_name" property="staffName"/>

+ 0 - 2
src/main/java/com/dk/mdm/mapper/mst/SupplierMapper.java

@@ -1,11 +1,9 @@
 package com.dk.mdm.mapper.mst;
 
-import com.dk.mdm.model.pojo.mst.Org;
 import com.dk.mdm.model.pojo.mst.Supplier;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.mst.SupplierQuery;
 import com.dk.mdm.model.response.mst.SpplierResponse;
-import com.dk.mdm.model.response.mst.StaffResponse;
 import com.dk.mdm.model.vo.mst.SupplierVo;
 import org.springframework.stereotype.Repository;
 

+ 2 - 2
src/main/java/com/dk/mdm/mapper/mst/UnitMapper.xml

@@ -31,10 +31,10 @@
     <sql id="Condition">
         <where>
             <if test="unitCode != null and unitCode != ''">
-                AND unit_code = #{unitCode}
+                AND unit_code LIKE concat('%',my_ex.likequery(#{unitCode}),'%')
             </if>
             <if test="unitName != null and unitName != ''">
-                AND unit_name = #{unitName}
+                AND unit_name LIKE concat('%',my_ex.likequery(#{unitName}),'%')
             </if>
             <if test="decimalPlaces != null">
                 AND decimal_places = #{decimalPlaces}

+ 1 - 1
src/main/java/com/dk/mdm/mapper/pur/PurchaseMapper.xml

@@ -441,7 +441,7 @@
         SELECT
         <include refid="Base_Column_List"/>
         FROM dkic_b.t_psi_purchase
-        WHERE pur_id = #{purId}
+        WHERE pur_id = #{id}
         for update
     </select>
 

+ 29 - 18
src/main/java/com/dk/mdm/mapper/sale/OrderItemMapper.xml

@@ -286,31 +286,42 @@
 
     <!-- 根据条件进行查询(出库用) -->
     <select id="selectByCondForOut" resultMap="BaseResultMapResponse">
-        SELECT t.item_id                                        as "fromItemId",
-               t.order_id                                       as "fromId",
+        SELECT t.item_id                                  as "fromItemId",
+               t.order_id                                 as "fromId",
                t.item_index,
                t.sku_id,
-               tmgs.sku_code                                       as "skuCode",
-               tmgs.sku_model                                      as "skuModel",
-               tmgs.sku_name                                       as "skuName",
-               t.item_qty                                       as "orderQty",
-               t.item_qty - t.outing_qty                     as "canOutingQty",
-               t.item_qty - t.outing_qty                     as outing_qty,
-               t.price_sale                                     as "priceOut",
+               tmgs.sku_code                              as "skuCode",
+               tmgs.sku_model                             as "skuModel",
+               tmgs.sku_name                              as "skuName",
+               t.item_qty                                 as "orderQty",
+               t.item_qty - t.outing_qty                  as "canOutingQty",
+               t.item_qty - t.outing_qty                  as outing_qty,
+               t.price_sale                               as "priceOut",
                t.price_sale * (t.item_qty - t.outing_qty) as outing_amt,
                t.non_std_code,
                t.remarks,
-               tpi.inv_id                                          as "invId",
-               tpi.wh_id                                           as "whId",
-               tpi.inv_qty                                         as "invQty",
-               tpi.usable_qty                                      as "usableQty",
-               tmw.wh_name                                         as "whName"
+               i.inv_id                                   as "invId",
+               i.wh_id                                    as "whId",
+               i.inv_qty                                  as "invQty",
+               i.usable_qty                               as "usableQty",
+               i.wh_name                                  as "whName"
         FROM dkic_b.t_psi_order_item as t
                  inner join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
-                 left join dkic_b.t_psi_inventory as tpi
-                           on tpi.sku_id = t.sku_id and tpi.non_std_code = t.non_std_code and
-                              tpi.cp_id = t.cp_id
-                 left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id
+                 left join(SELECT T.*
+                           FROM (select tpi.inv_id,
+                                        tpi.wh_id,
+                                        tpi.inv_qty,
+                                        tpi.usable_qty,
+                                        tpi.sku_id,
+                                        tpi.non_std_code,
+                                        tpi.cp_id,
+                                        tmw.wh_name,
+                                        rank()
+                                        over (partition by tpi.cp_id,tpi.sku_id,tpi.non_std_code order by tpi.inv_id) as RK
+                                 from dkic_b.t_psi_inventory as tpi
+                                          left join dkic_b.t_mst_warehouse as tmw on tmw.wh_id = tpi.wh_id) T
+                           WHERE T.RK = 1) as i
+                          on i.sku_id = t.sku_id and i.non_std_code = t.non_std_code and i.cp_id = t.cp_id
         where t.flg_valid
           and t.item_qty > t.outing_qty
           and t.order_id = #{orderId}::uuid

+ 19 - 18
src/main/java/com/dk/mdm/model/pojo/ivt/IntoReturnItem.java

@@ -159,41 +159,42 @@ public class IntoReturnItem extends PageInfo<IntoReturnItem> implements Serializ
     /**
      * 入库状态
      */
-    @Excel(name = "库状态")
+    @Excel(name = "库状态")
     @ApiModelProperty(value = "入库状态")
-    private String intoStatus;
+    private String outStatus;
+
 
 
     /**
-     * 库中数量
+     * 库中数量
      */
-    @Excel(name = "库中数量")
-    @ApiModelProperty(value = "库中数量")
-    private BigDecimal intoingQty;
+    @Excel(name = "库中数量")
+    @ApiModelProperty(value = "库中数量")
+    private BigDecimal outingQty;
 
 
     /**
-     * 库中金额
+     * 库中金额
      */
-    @Excel(name = "库中金额")
-    @ApiModelProperty(value = "库中金额")
-    private BigDecimal intoingAmt;
+    @Excel(name = "库中金额")
+    @ApiModelProperty(value = "库中金额")
+    private BigDecimal outingAmt;
 
 
     /**
-     * 已库数量
+     * 已库数量
      */
-    @Excel(name = "已库数量")
-    @ApiModelProperty(value = "已库数量")
-    private BigDecimal intoQty;
+    @Excel(name = "已库数量")
+    @ApiModelProperty(value = "已库数量")
+    private BigDecimal outQty;
 
 
     /**
-     * 已库金额
+     * 已库金额
      */
-    @Excel(name = "已库金额")
-    @ApiModelProperty(value = "已库金额")
-    private BigDecimal intoAmt;
+    @Excel(name = "已库金额")
+    @ApiModelProperty(value = "已库金额")
+    private BigDecimal outAmt;
 
 
     /**

+ 19 - 18
src/main/java/com/dk/mdm/model/query/ivt/IntoReturnItemQuery.java

@@ -158,41 +158,42 @@ public class IntoReturnItemQuery extends PageInfo<IntoReturnItemQuery> implement
     /**
      * 入库状态
      */
-    @Excel(name = "库状态")
+    @Excel(name = "库状态")
     @ApiModelProperty(value = "入库状态")
-    private String intoStatus;
+    private String outStatus;
+
 
 
     /**
-     * 库中数量
+     * 库中数量
      */
-    @Excel(name = "库中数量")
-    @ApiModelProperty(value = "库中数量")
-    private BigDecimal intoingQty;
+    @Excel(name = "库中数量")
+    @ApiModelProperty(value = "库中数量")
+    private BigDecimal outingQty;
 
 
     /**
-     * 库中金额
+     * 库中金额
      */
-    @Excel(name = "库中金额")
-    @ApiModelProperty(value = "库中金额")
-    private BigDecimal intoingAmt;
+    @Excel(name = "库中金额")
+    @ApiModelProperty(value = "库中金额")
+    private BigDecimal outingAmt;
 
 
     /**
-     * 已库数量
+     * 已库数量
      */
-    @Excel(name = "已库数量")
-    @ApiModelProperty(value = "已库数量")
-    private BigDecimal intoQty;
+    @Excel(name = "已库数量")
+    @ApiModelProperty(value = "已库数量")
+    private BigDecimal outQty;
 
 
     /**
-     * 已库金额
+     * 已库金额
      */
-    @Excel(name = "已库金额")
-    @ApiModelProperty(value = "已库金额")
-    private BigDecimal intoAmt;
+    @Excel(name = "已库金额")
+    @ApiModelProperty(value = "已库金额")
+    private BigDecimal outAmt;
 
 
     /**

+ 19 - 18
src/main/java/com/dk/mdm/model/response/ivt/IntoReturnItemResponse.java

@@ -163,41 +163,42 @@ public class IntoReturnItemResponse  implements Serializable {
     /**
      * 入库状态
      */
-    @Excel(name = "库状态")
+    @Excel(name = "库状态")
     @ApiModelProperty(value = "入库状态")
-    private String intoStatus;
+    private String outStatus;
+
 
 
     /**
-     * 库中数量
+     * 库中数量
      */
-    @Excel(name = "库中数量")
-    @ApiModelProperty(value = "库中数量")
-    private BigDecimal intoingQty;
+    @Excel(name = "库中数量")
+    @ApiModelProperty(value = "库中数量")
+    private BigDecimal outingQty;
 
 
     /**
-     * 库中金额
+     * 库中金额
      */
-    @Excel(name = "库中金额")
-    @ApiModelProperty(value = "库中金额")
-    private BigDecimal intoingAmt;
+    @Excel(name = "库中金额")
+    @ApiModelProperty(value = "库中金额")
+    private BigDecimal outingAmt;
 
 
     /**
-     * 已库数量
+     * 已库数量
      */
-    @Excel(name = "已库数量")
-    @ApiModelProperty(value = "已库数量")
-    private BigDecimal intoQty;
+    @Excel(name = "已库数量")
+    @ApiModelProperty(value = "已库数量")
+    private BigDecimal outQty;
 
 
     /**
-     * 已库金额
+     * 已库金额
      */
-    @Excel(name = "已库金额")
-    @ApiModelProperty(value = "已库金额")
-    private BigDecimal intoAmt;
+    @Excel(name = "已库金额")
+    @ApiModelProperty(value = "已库金额")
+    private BigDecimal outAmt;
 
 
     /**

+ 13 - 1
src/main/java/com/dk/mdm/model/response/mst/CusFollowVOResponse.java → src/main/java/com/dk/mdm/model/response/mst/CusFollowResponse.java

@@ -12,6 +12,7 @@ import com.dk.common.infrastructure.handler.UuidTypeHandler;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import io.swagger.models.auth.In;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -30,7 +31,7 @@ import java.time.LocalDateTime;
 @ExportTitle("客户跟进")
 @TableName(value = "t_crm_cus_follow", autoResultMap = true)
 @ApiModel(value="实体类:客户跟进", description="表名:t_crm_cus_follow")
-public class CusFollowVOResponse implements Serializable {
+public class CusFollowResponse implements Serializable {
 
     /*
      * 数据库字段
@@ -216,6 +217,17 @@ public class CusFollowVOResponse implements Serializable {
     private Integer cpId;
 
 
+    private String cusName;
+    private String cusPhone;
+    private String orgName;
+    private String staffName;
+    private String followStaffName;
+    private String addressFull;
+    private Integer followCount;
+
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @TableField(typeHandler = TimestampTypeHandler.class)
+    private LocalDateTime createTime;
 
 
     private static final long serialVersionUID = 1L;

+ 0 - 245
src/main/java/com/dk/mdm/model/response/mst/StaffResponse.java

@@ -1,245 +0,0 @@
-package com.dk.mdm.model.response.mst;
-
-import cn.afterturn.easypoi.excel.annotation.Excel;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
-import com.dk.common.infrastructure.annotaiton.ExportTitle;
-import com.dk.common.infrastructure.handler.TimestampTypeHandler;
-import com.dk.common.infrastructure.handler.UuidListTypeHandler;
-import com.dk.common.infrastructure.handler.UuidTypeHandler;
-import com.dk.common.model.pojo.PageInfo;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import io.swagger.annotations.ApiModel;
-import io.swagger.annotations.ApiModelProperty;
-import lombok.AllArgsConstructor;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
-import lombok.NoArgsConstructor;
-import lombok.experimental.Accessors;
-
-import java.io.Serializable;
-import java.time.LocalDateTime;
-import java.util.List;
-
-/**
- *  员工
- */
-@Data
-@AllArgsConstructor
-@NoArgsConstructor
-@EqualsAndHashCode(callSuper = true)
-@Accessors(chain = true)
-@ExportTitle("员工")
-@TableName(value = "t_mst_staff", autoResultMap = true)
-@ApiModel(value="实体类:员工", description="表名:t_mst_staff")
-public class StaffResponse extends PageInfo<StaffResponse> implements Serializable {
-
-    /*
-     * 数据库字段
-     */
-
-    /**
-     * 员工ID
-     */
-    @TableId(value = "staff_id")
-    @ApiModelProperty(value = "员工ID")
-    @TableField(typeHandler = UuidTypeHandler.class)
-    private String staffId;
-
-
-    /**
-     * 员工编码
-     */
-    @Excel(name = "员工编码")
-    @ApiModelProperty(value = "员工编码")
-    private String staffCode;
-
-
-    /**
-     * 员工名称
-     */
-    @Excel(name = "员工名称")
-    @ApiModelProperty(value = "员工名称")
-    private String staffName;
-
-    /**
-     * 员工电话
-     */
-    @Excel(name = "员工电话")
-    @ApiModelProperty(value = "员工电话")
-    private String staffPhone;
-
-    /**
-     * 员工工种
-     */
-    @Excel(name = "微信用户")
-    @ApiModelProperty(value = "微信用户")
-    private String wxUserId;
-
-
-    /**
-     * 组织部门
-     */
-    @Excel(name = "组织部门")
-    @ApiModelProperty(value = "组织部门")
-    @TableField(typeHandler = UuidTypeHandler.class)
-    private String orgId;
-
-
-    /**
-     * 备注
-     */
-    @Excel(name = "备注")
-    @ApiModelProperty(value = "备注")
-    private String remarks;
-
-    /**
-     * 登录标识
-     */
-    @ApiModelProperty(value = "登录标识")
-    private Boolean flgCanLogin;
-
-    /**
-     * 有效标识 (1:正常 0:停用)
-     */
-    @Excel(name = "有效标识 (1:正常 0:停用)")
-    @ApiModelProperty(value = "有效标识 (1:正常 0:停用)")
-    private Boolean flgValid;
-
-    /**
-     * @desc   : 角色list
-     */
-    @ApiModelProperty(value = "角色list")
-    @TableField(typeHandler = UuidListTypeHandler.class)
-    private List<String> roleIds;
-
-    /**
-     * @desc   : 角色
-     */
-    @ApiModelProperty(value = "员工角色名称")
-    private String roleNames;
-
-
-    /**
-     * 企业ID
-     */
-    @Excel(name = "企业ID")
-    @ApiModelProperty(value = "企业ID")
-    private Integer cpId;
-
-    /**
-     * 企业编码
-     */
-    @Excel(name = "企业编码")
-    @ApiModelProperty(value = "企业编码")
-    private String cpCode;
-
-    /**
-     * 登录标识1能登录 0不能登录
-     */
-    @Excel(name = "登录标识")
-    @ApiModelProperty(value = "登录标识")
-    private Integer hrStatus;
-
-    /**
-     * @desc   : 登录标识
-     */
-    @ApiModelProperty(value = "登录标识")
-    private String hrStatusName;
-
-    /**
-     * 创建时间 (触发器自动处理)
-     */
-    @Excel(name = "创建时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
-    @ApiModelProperty(value = "创建时间 (触发器自动处理)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime opCreateTime;
-
-
-    /**
-     * 创建用户 (触发器自动处理)
-     */
-    @Excel(name = "创建用户 (触发器自动处理)")
-    @ApiModelProperty(value = "创建用户 (触发器自动处理)")
-    @TableField(typeHandler = UuidTypeHandler.class)
-    private String opCreateUserId;
-
-
-    /**
-     * 修改时间 (触发器自动处理)
-     */
-    @Excel(name = "修改时间 (触发器自动处理)", format = "yyyy-MM-dd HH:mm:ss", width = 20)
-    @ApiModelProperty(value = "修改时间 (触发器自动处理)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime opUpdateTime;
-
-
-    /**
-     * 修改用户 (触发器自动处理)
-     */
-    @Excel(name = "修改用户 (触发器自动处理)")
-    @ApiModelProperty(value = "修改用户 (触发器自动处理)")
-    @TableField(typeHandler = UuidTypeHandler.class)
-    private String opUpdateUserId;
-
-
-    /**
-     * 数据操作应用 (触发器自动处理)
-     */
-    @Excel(name = "数据操作应用 (触发器自动处理)")
-    @ApiModelProperty(value = "数据操作应用 (触发器自动处理)")
-    private String opAppCode;
-
-
-    /**
-     * 数据时间戳 (触发器自动处理)
-     */
-    @Excel(name = "数据时间戳 (触发器自动处理)")
-    @ApiModelProperty(value = "数据时间戳 (触发器自动处理)")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime opTimestamp;
-
-
-    /**
-     * 数据操作数据库用户 (触发器自动处理)
-     */
-    @Excel(name = "数据操作数据库用户 (触发器自动处理)")
-    @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
-    private String opDbUser;
-
-
-    /*
-     * 相关属性
-     * @TableField(exist = false)
-     */
-
-    @ApiModelProperty(value = "关联工号ID")
-    private List<Integer> userIds;
-
-    /**
-     * 组织部门名称
-     */
-    @Excel(name = "组织部门名称")
-    @ApiModelProperty(value = "组织部门名称")
-    private String orgName;
-
-    /**
-     * 员工状态名称
-     */
-    @Excel(name = "员工状态名称")
-    @ApiModelProperty(value = "员工状态名称")
-    private String staffStatusName;
-
-    /**
-     * 部门全称
-     */
-    @Excel(name = "部门全称")
-    @ApiModelProperty(value = "部门全称")
-    private String orgLevelName;
-    private static final long serialVersionUID = 1L;
-
-}

+ 19 - 18
src/main/java/com/dk/mdm/model/vo/ivt/IntoReturnItemVO.java

@@ -157,41 +157,42 @@ public class IntoReturnItemVO  implements Serializable {
     /**
      * 入库状态
      */
-    @Excel(name = "库状态")
+    @Excel(name = "库状态")
     @ApiModelProperty(value = "入库状态")
-    private String intoStatus;
+    private String outStatus;
+
 
 
     /**
-     * 库中数量
+     * 库中数量
      */
-    @Excel(name = "库中数量")
-    @ApiModelProperty(value = "库中数量")
-    private BigDecimal intoingQty;
+    @Excel(name = "库中数量")
+    @ApiModelProperty(value = "库中数量")
+    private BigDecimal outingQty;
 
 
     /**
-     * 库中金额
+     * 库中金额
      */
-    @Excel(name = "库中金额")
-    @ApiModelProperty(value = "库中金额")
-    private BigDecimal intoingAmt;
+    @Excel(name = "库中金额")
+    @ApiModelProperty(value = "库中金额")
+    private BigDecimal outingAmt;
 
 
     /**
-     * 已库数量
+     * 已库数量
      */
-    @Excel(name = "已库数量")
-    @ApiModelProperty(value = "已库数量")
-    private BigDecimal intoQty;
+    @Excel(name = "已库数量")
+    @ApiModelProperty(value = "已库数量")
+    private BigDecimal outQty;
 
 
     /**
-     * 已库金额
+     * 已库金额
      */
-    @Excel(name = "已库金额")
-    @ApiModelProperty(value = "已库金额")
-    private BigDecimal intoAmt;
+    @Excel(name = "已库金额")
+    @ApiModelProperty(value = "已库金额")
+    private BigDecimal outAmt;
 
 
     /**

+ 52 - 6
src/main/java/com/dk/mdm/model/vo/mst/CusFollowVO.java

@@ -280,16 +280,62 @@ public class CusFollowVO implements Serializable {
     private String opDbUser;
 
 
-    /*
-     * 相关属性
-     * @TableField(exist = false)
+    /**
+     * 客户名称
      */
+    @Excel(name = "客户名称")
+    @ApiModelProperty(value = "客户名称")
+    private String cusName;
 
-    /*
-     * 关联属性 + 查询条件
-     * @TableField(exist = false)
+
+    /**
+     * 客户电话
+     */
+    @Excel(name = "客户电话")
+    @ApiModelProperty(value = "客户电话")
+    private String cusPhone;
+
+
+    /**
+     * 行政区划 (a1:省 a2:市 a3:区)
+     */
+    @Excel(name = "行政区划 (a1:省 a2:市 a3:区)")
+    @ApiModelProperty(value = "行政区划 (a1:省 a2:市 a3:区)")
+    @TableField(typeHandler = JsonTypeHandler.class)
+    private JSONObject addressArea;
+
+
+    /**
+     * 小区或POI
      */
+    @Excel(name = "小区或POI")
+    @ApiModelProperty(value = "小区或POI")
+    private String addressName;
+
 
+    /**
+     * 门牌号
+     */
+    @Excel(name = "门牌号")
+    @ApiModelProperty(value = "门牌号")
+    private String addressNo;
+
+
+    /**
+     * 地址坐标(gcj02) (LAT:纬度的值 LON:经度的值)
+     */
+    @Excel(name = "地址坐标(gcj02) (LAT:纬度的值 LON:经度的值)")
+    @ApiModelProperty(value = "地址坐标(gcj02) (LAT:纬度的值 LON:经度的值)")
+    @TableField(typeHandler = JsonTypeHandler.class)
+    private JSONObject addressGcj02;
+
+
+    /**
+     * 详细地址
+     */
+    @Excel(name = "详细地址")
+    @ApiModelProperty(value = "详细地址")
+    private String addressFull;
 
     private static final long serialVersionUID = 1L;
 

+ 6 - 32
src/main/java/com/dk/mdm/service/common/CommonService.java

@@ -1,13 +1,11 @@
 package com.dk.mdm.service.common;
 
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.infrastructure.enums.ErrorCodeEnum;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.common.model.pojo.PageList;
 import com.dk.common.model.vo.core.StaffEntity;
-import com.dk.common.model.vo.core.UserVO;
 import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
@@ -15,16 +13,14 @@ import com.dk.common.service.BaseService;
 import com.dk.mdm.mapper.common.CommonMapper;
 import com.dk.mdm.infrastructure.util.AuthUtils;
 import com.dk.mdm.mapper.mst.StaffMapper;
-import com.dk.mdm.model.response.mst.StaffResponse;
+import com.dk.common.model.response.mst.StaffResponse;
 import lombok.extern.slf4j.Slf4j;
 import org.postgresql.util.PGobject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.CollectionUtils;
 
 import java.util.*;
-import java.util.stream.Collectors;
 
 /**
  * @author : 周兴
@@ -198,17 +194,6 @@ public class CommonService extends BaseService<Map<String, Object>> {
     }
 
     /**
-     * @desc : 获取商品品牌
-     * @author : 夏常明
-     * @date : 2023/1/10 14:24
-     */
-    public ResponseResultVO<List<Map<String, Object>>> getBrand(Map<String, Object> param) {
-        // 获取系统基础数据
-        List<Map<String, Object>> list = commonMapper.getBrand(param);
-        return ResponseResultUtil.success(list);
-    }
-
-    /**
      * @desc : 获取角色
      * @author : 姜宁
      * @date : 2023/1/29 14:28
@@ -294,22 +279,6 @@ public class CommonService extends BaseService<Map<String, Object>> {
     }
 
     /**
-     * @desc : 获取组织部门
-     * @author : 姜宁
-     * @date : 2023/2/1 14:09
-     */
-    public ResponseResultVO<PageList<Map<String, Object>>> getOrganizationByPage(Map<String, Object> param) {
-        // 校验分页参数
-        if (param.get("pageSize") == null || param.get("currentPage") == null) {
-            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL, "请检查分页参数!");
-        }
-        // 分页参数赋值
-        param = this.getLimit(param);
-        return super.mergeListWithCount(param, commonMapper.getOrganizationByPage(param),
-                commonMapper.getOrganizationCountByPage(param));
-    }
-
-    /**
      * @desc : 获取数据字典
      * @author : 姜宁
      * @date : 2023/2/7 14:47
@@ -730,6 +699,11 @@ public class CommonService extends BaseService<Map<String, Object>> {
             map.put("kindType","量尺状态");
             list = commonMapper.getDataKind(map);
         }
+        //跟进方式
+        if (dataSourceCode.equals("followType")) {
+            map.put("kindType","跟进方式");
+            list = commonMapper.getDataKind(map);
+        }
         return ResponseResultUtil.success(list);
     }
 }

+ 28 - 11
src/main/java/com/dk/mdm/service/ivt/InboundOtherService.java

@@ -117,7 +117,10 @@ public class InboundOtherService extends BaseService<Inbound> {
 		//入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
 		if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
 			inboundVO.setIntoQty(inboundVO.getIntoingQty())
-					.setIntoAmt(inboundVO.getIntoingAmt());
+					.setIntoAmt(inboundVO.getIntoingAmt())
+					.setIntoingQty(BigDecimal.ZERO)
+					.setIntoingAmt(BigDecimal.ZERO)
+			;
 		}
 		//实体转换
 		Inbound inbound = inboundConvert.convertToPo(inboundVO);
@@ -141,14 +144,17 @@ public class InboundOtherService extends BaseService<Inbound> {
 			//入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
 			if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
 				inboundItemVO.setIntoQty(inboundItemVO.getIntoingQty())
-						.setIntoAmt(inboundItemVO.getIntoingAmt());
+						.setIntoAmt(inboundItemVO.getIntoingAmt())
+						.setIntoingQty(BigDecimal.ZERO)
+						.setIntoingAmt(BigDecimal.ZERO)
+				;
 			}
 			//成本单价
 			inboundItemVO.setCostPrice(inboundItemVO.getCostPrice());
 			//成本金额
-			inboundItemVO.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP));
+			inboundItemVO.setCostAmt((inboundItemVO.getIntoingQty().add(inboundItemVO.getIntoQty())).multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP));
 			//库存数量  已入库-出库
-			inboundItemVO.setInvQty(inboundItemVO.getReturnQty().subtract(inboundItemVO.getOutQty()));
+			inboundItemVO.setInvQty(inboundItemVO.getIntoQty().subtract(inboundItemVO.getOutQty()));
 			//入库状态
 			inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
 			//实体转换
@@ -186,11 +192,14 @@ public class InboundOtherService extends BaseService<Inbound> {
 			}
 			for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
 				if (inboundItemVO.getIntoId() != null) {
+					InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getIntoId());
 					//编辑明细
-					inboundItemVO.setCostPrice(inboundItemVO.getPriceInto())
-							.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
-							.setIntoQty(inboundItemVO.getIntoingQty())
-							.setIntoAmt(inboundItemVO.getIntoingAmt());
+					inboundItemVO
+							.setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
+							.setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
+							.setIntoingQty(inboundItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()))
+							.setIntoingAmt(inboundItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()))
+					;
 					//入库状态
 					String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
 					inboundItemVO.setIntoStatus(intoStatus);
@@ -210,7 +219,7 @@ public class InboundOtherService extends BaseService<Inbound> {
 							.setIntoAmt(inboundItemVO.getIntoingAmt())
 							.setIntoId(inboundVO.getIntoId())
 							.setCostPrice(inboundItemVO.getPriceInto())
-							.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+							.setCostAmt((inboundItemVO.getIntoingQty().add(inboundItemVO.getIntoQty())).multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
 							.setIntoType(Constant.IntoType.OTHER.getName());
 					//入库状态
 					String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
@@ -238,10 +247,14 @@ public class InboundOtherService extends BaseService<Inbound> {
 			//region 编辑总单
 			BigDecimal sumIntoQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
 			BigDecimal sumIntoAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+			BigDecimal sumIntoingQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+			BigDecimal sumIntoingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
 			inboundVO.setIntoQty(sumIntoQty);
 			inboundVO.setIntoAmt(sumIntoAmt);
+			inboundVO.setIntoingQty(sumIntoingQty);
+			inboundVO.setIntoingAmt(sumIntoingAmt);
 			//已入库数量==入库中数量   入库完成
-			if(sumIntoQty.compareTo(inboundVO.getIntoQty())==0){
+			if(inboundVO.getIntoQty().compareTo(inboundVO.getIntoingQty())==0){
 				//已入库
 				inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
 			} else {
@@ -251,7 +264,7 @@ public class InboundOtherService extends BaseService<Inbound> {
 			//实体转换
 			Inbound inbound = inboundConvert.convertToPo(inboundVO);
 			//修改
-			super.update(inbound);
+			inboundMapper.updateById(inbound);
 			//endregion
 
 			//todo 如果是已入库 调用库存  后续写库存这里补上
@@ -276,6 +289,8 @@ public class InboundOtherService extends BaseService<Inbound> {
 		inbound.setIntoId(inboundResponse.getIntoId())
 				.setIntoDate(null)
 				.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
+				.setIntoingQty(inboundResponse.getIntoingQty().add(inboundResponse.getIntoQty()))
+				.setIntoingAmt(inboundResponse.getIntoingAmt().add(inboundResponse.getIntoAmt()))
 				.setIntoQty(BigDecimal.ZERO)
 				.setIntoAmt(BigDecimal.ZERO);
 		inboundMapper.updateById(inbound);
@@ -289,6 +304,8 @@ public class InboundOtherService extends BaseService<Inbound> {
 			InboundItem inboundItem = new InboundItem();
 			inboundItem.setIntoId(inbound.getIntoId())
 					.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
+					.setIntoingQty(inboundItemResponse.getIntoingQty().add(inboundItemResponse.getIntoQty()))
+					.setIntoingAmt(inboundItemResponse.getIntoingAmt().add(inboundItemResponse.getIntoAmt()))
 					.setIntoQty(BigDecimal.ZERO)
 					.setIntoAmt(BigDecimal.ZERO)
 					.setItemId(inboundItemResponse.getItemId());

+ 99 - 27
src/main/java/com/dk/mdm/service/ivt/InboundPurchaseService.java

@@ -90,6 +90,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 	/**
 	 * @desc   : 采购入库新建
 	 * @date   : 2024/3/7 14:13
+	 * 入库中数量/金额  已入库数量/金额  由调用方传入
 	 * @author : 寇珊珊
 	 */
 	@Transactional(rollbackFor = {Exception.class})
@@ -101,13 +102,45 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 				setIntoNo(codeMap.get("outNote").toString());
 		//入库类型
 		inboundVO.setIntoType(Constant.IntoType.SALE.getName());
-		//入库状态  待入库
-		inboundVO.setIntoStatus(Constant.IntoStatus.DAIRUKU.getName());
+		//自动入库标识
+		if (inboundVO.getAutomaticFlg()) {
+			//已入库
+			inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
+		} else {
+			//入库中
+			inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
+		}
+		//入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
+		if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
+			inboundVO.setIntoQty(inboundVO.getIntoingQty())
+					.setIntoAmt(inboundVO.getIntoingAmt())
+					.setIntoingQty(BigDecimal.ZERO)
+					.setIntoingAmt(BigDecimal.ZERO)
+			;
+		}
 		//实体转换
 		Inbound inbound = inboundConvert.convertToPo(inboundVO);
 		inboundMapper.insert(inbound);
 		//endregion
 
+		//region 采购总单
+		if(inboundVO.getFromId()!=null){
+			PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
+			Purchase purchaseUpdate = new Purchase();
+			purchaseUpdate.setPurId(inboundVO.getFromId());
+			purchaseUpdate.setIntoingQty(purchaseResponse.getIntoingQty().subtract(inboundVO.getIntoingQty()));
+			purchaseUpdate.setIntoingAmt(purchaseResponse.getIntoingAmt().subtract(inboundVO.getIntoingAmt()));
+			purchaseUpdate.setIntoAmt(purchaseResponse.getIntoQty().add(inboundVO.getIntoAmt()));
+			purchaseUpdate.setIntoQty(purchaseResponse.getIntoAmt().add(inboundVO.getIntoQty()));
+			//入库状态
+			String intoStatus = this.setIntoStatus(purchaseUpdate.getIntoingQty(), purchaseUpdate.getIntoQty());
+			purchaseUpdate.setIntoStatus(intoStatus);
+			//修改
+			purchaseMapper.updateById(purchaseUpdate);
+		}
+		//endregion
+
+
 		//region 明细
 		//校验明细
 		if (inboundVO.getItemList().size() == 0) {
@@ -115,6 +148,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 					ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
 		}
 		for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
+			//region  入库明细
 			Map<String , Object> map = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUNDITEM.getName(),true);
 			//明细id
 			inboundItemVO.setItemId(map.get("outId").toString());
@@ -122,17 +156,43 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 			inboundItemVO.setIntoId(inboundVO.getIntoId());
 			//入库类型
 			inboundItemVO.setIntoType(inboundVO.getIntoType());
+			//入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
+			if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
+				inboundItemVO.setIntoQty(inboundItemVO.getIntoingQty())
+						.setIntoAmt(inboundItemVO.getIntoingAmt())
+						.setIntoingQty(BigDecimal.ZERO)
+						.setIntoingAmt(BigDecimal.ZERO)
+				;
+			}
 			//成本单价
 			inboundItemVO.setCostPrice(inboundItemVO.getCostPrice());
 			//成本金额
-			inboundItemVO.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP));
+			inboundItemVO.setCostAmt((inboundItemVO.getIntoingQty().add(inboundItemVO.getIntoQty())).multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP));
 			//库存数量  已入库-出库
-			inboundItemVO.setInvQty(inboundItemVO.getReturnQty().subtract(inboundItemVO.getOutQty()));
+			inboundItemVO.setInvQty(inboundItemVO.getIntoQty().subtract(inboundItemVO.getOutQty()));
 			//入库状态
 			inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
 			//实体转换
 			InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
 			inboundItemMapper.insert(inboundItem);
+			//endregion
+
+			//region 采购明细
+			if(inboundItemVO.getFromItemId()!=null){
+				//根据id查询
+				PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
+				PurchaseItem  purchaseItem = new PurchaseItem();
+				purchaseItem.setItemId(inboundItemVO.getFromItemId());
+				purchaseItem.setIntoingQty(purchaseItemResponse.getIntoingQty().add(inboundItemVO.getIntoingQty()));
+				purchaseItem.setIntoingAmt(purchaseItemResponse.getIntoingAmt().add(inboundItemVO.getIntoingAmt()));
+				purchaseItem.setIntoQty(purchaseItemResponse.getIntoQty().add(inboundItemVO.getIntoQty()));
+				purchaseItem.setIntoAmt(purchaseItemResponse.getIntoAmt().add(inboundItemVO.getIntoAmt()));
+				//入库状态
+				String intoStatus = this.setIntoStatus(purchaseItem.getIntoingQty(), purchaseItem.getIntoQty());
+				purchaseItem.setIntoStatus(intoStatus);
+				purchaseItemMapper.updateById(purchaseItem);
+			}
+			//endregion
 		}
 		//endregion
 
@@ -165,12 +225,14 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 			}
 			for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
 				if (inboundItemVO.getIntoId() != null) {
-
+					InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getIntoId());
 					//编辑明细
-					inboundItemVO.setCostPrice(inboundItemVO.getPriceInto())
-							.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
-							.setIntoQty(inboundItemVO.getIntoingQty())
-							.setIntoAmt(inboundItemVO.getIntoingAmt());
+					inboundItemVO
+							.setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
+							.setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
+							.setIntoingQty(inboundItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()))
+							.setIntoingAmt(inboundItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()))
+					;
 					//入库状态
 					String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
 					inboundItemVO.setIntoStatus(intoStatus);
@@ -189,7 +251,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 							.setIntoAmt(inboundItemVO.getIntoingAmt())
 							.setIntoId(inboundVO.getIntoId())
 							.setCostPrice(inboundItemVO.getPriceInto())
-							.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+							.setCostAmt((inboundItemVO.getIntoingQty().add(inboundItemVO.getIntoQty())).multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
 							.setIntoType(Constant.IntoType.SALE.getName());
 					//入库状态
 					String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
@@ -205,8 +267,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 					PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
 					PurchaseItem  purchaseItem = new PurchaseItem();
 					purchaseItem.setItemId(purchaseItemResponse.getItemId());
-					purchaseItem.setIntoingQty(purchaseItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoQty()));
-					purchaseItem.setIntoingAmt(purchaseItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoAmt()));
+					purchaseItem.setIntoingQty(purchaseItemResponse.getIntoingQty().add(inboundItemVO.getIntoingQty()));
+					purchaseItem.setIntoingAmt(purchaseItemResponse.getIntoingAmt().add(inboundItemVO.getIntoingAmt()));
 					purchaseItem.setIntoQty(purchaseItemResponse.getIntoQty().add(inboundItemVO.getIntoQty()));
 					purchaseItem.setIntoAmt(purchaseItemResponse.getIntoAmt().add(inboundItemVO.getIntoAmt()));
 					//入库状态
@@ -221,9 +283,13 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 			//region 删除明细
 			BigDecimal sumDelIntoQty = BigDecimal.ZERO;
 			BigDecimal sumDelIntoAmt = BigDecimal.ZERO;
+			BigDecimal sumDelIntoingQty = BigDecimal.ZERO;
+			BigDecimal sumDelIntoingAmt = BigDecimal.ZERO;
 			if (inboundVO.getDeleteItemList() != null) {
 				 sumDelIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
 				 sumDelIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+				 sumDelIntoingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+				 sumDelIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
 				for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
 					if (inboundItemVO.getItemId() != null) {
 						InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
@@ -231,21 +297,19 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 						inboundItemMapper.updateById(inboundItem);
 					}
 					//region  采购
-					if(inboundVO.getFromId()!=null){
+					if(inboundItemVO.getFromItemId()!=null){
 						//region 采购订单明细
-						List<PurchaseItemResponse> purchaseItemResponses = purchaseItemMapper.selectByCond(new PurchaseItemQuery().setPurId(inboundVO.getFromId()));
-						for (PurchaseItemResponse purchaseItemResponse : purchaseItemResponses) {
-							PurchaseItem  purchaseItem = new PurchaseItem();
+						PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
+						PurchaseItem  purchaseItem = new PurchaseItem();
 							purchaseItem.setItemId(purchaseItemResponse.getItemId());
-							purchaseItem.setIntoingQty(purchaseItemResponse.getIntoingQty().add(purchaseItemResponse.getIntoQty()));
-							purchaseItem.setIntoingAmt(purchaseItemResponse.getIntoingAmt().add(purchaseItemResponse.getIntoAmt()));
-							purchaseItem.setIntoQty(BigDecimal.ZERO);
-							purchaseItem.setIntoingAmt(BigDecimal.ZERO);
+							purchaseItem.setIntoingQty(purchaseItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()));
+							purchaseItem.setIntoingAmt(purchaseItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()));
+							purchaseItem.setIntoQty(purchaseItemResponse.getIntoQty().subtract(inboundItemVO.getIntoQty()));
+							purchaseItem.setIntoAmt(purchaseItemResponse.getIntoAmt().subtract(inboundItemVO.getIntoAmt()));
 							//入库状态
 							String intoStatus = this.setIntoStatus(purchaseItem.getIntoingQty(), purchaseItem.getIntoQty());
 							purchaseItem.setIntoStatus(intoStatus);
 							purchaseItemMapper.updateById(purchaseItem);
-						}
 						//endregion
 					}
 					//endregion
@@ -257,10 +321,14 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 			//region 编辑总单
 			BigDecimal sumIntoQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
 			BigDecimal sumIntoAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+			BigDecimal sumIntoingQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+			BigDecimal sumIntoingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
 			inboundVO.setIntoQty(sumIntoQty);
 			inboundVO.setIntoAmt(sumIntoAmt);
+			inboundVO.setIntoingQty(sumIntoingQty);
+			inboundVO.setIntoingAmt(sumIntoingAmt);
 			//已入库数量==入库中数量   入库完成
-			if(sumIntoQty.compareTo(inboundVO.getIntoQty())==0){
+			if(inboundVO.getIntoQty().compareTo(inboundVO.getIntoingQty())==0){
 				//已入库
 				inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
 			} else {
@@ -270,7 +338,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 			//实体转换
 			Inbound inbound = inboundConvert.convertToPo(inboundVO);
 			//修改
-			super.update(inbound);
+			inboundMapper.updateById(inbound);
 			//endregion
 
 			//region  修改采购订单
@@ -278,10 +346,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 				PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
 				Purchase  purchase = new Purchase();
 				purchase.setPurId(purchaseResponse.getPurId());
-				purchase.setIntoQty(purchaseResponse.getIntoQty().subtract(sumIntoQty.add(sumDelIntoQty)));
-				purchase.setIntoAmt(purchaseResponse.getIntoAmt().subtract(sumIntoAmt.add(sumDelIntoAmt)));
-				purchase.setIntoingQty(purchaseResponse.getIntoingQty().add(sumIntoQty).subtract(sumDelIntoQty));
-				purchase.setIntoingAmt(purchaseResponse.getIntoingAmt().add(sumIntoAmt).subtract(sumDelIntoAmt));
+				purchase.setIntoQty(purchaseResponse.getIntoQty().add(sumIntoQty).subtract(sumDelIntoQty));
+				purchase.setIntoAmt(purchaseResponse.getIntoAmt().add(sumIntoAmt).subtract(sumDelIntoAmt));
+				purchase.setIntoingQty(purchaseResponse.getIntoingQty().subtract(sumIntoingQty).subtract(sumDelIntoingQty));
+				purchase.setIntoingAmt(purchaseResponse.getIntoingAmt().subtract(sumIntoingAmt).subtract(sumDelIntoingAmt));
 				//入库状态
 				String intoStatus = this.setIntoStatus(purchase.getIntoingQty(), purchase.getIntoQty());
 				purchase.setIntoStatus(intoStatus);
@@ -331,6 +399,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 		inbound.setIntoId(inboundVO.getIntoId());
 		inbound.setIntoDate(null);
 		inbound.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
+		inbound.setIntoingQty(inboundResponse.getIntoingQty().add(inboundResponse.getIntoQty()));
+		inbound.setIntoingAmt(inboundResponse.getIntoingAmt().add(inboundResponse.getIntoAmt()));
 		inbound.setIntoQty(BigDecimal.ZERO);
 		inbound.setIntoAmt(BigDecimal.ZERO);
 		inboundMapper.updateById(inbound);
@@ -360,6 +430,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 			InboundItem inboundItem = new InboundItem();
 			inboundItem.setIntoId(inbound.getIntoId())
 					.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
+					.setIntoingQty(inboundItemResponse.getIntoingQty().add(inboundItemResponse.getIntoQty()))
+					.setIntoingAmt(inboundItemResponse.getIntoingAmt().add(inboundItemResponse.getIntoAmt()))
 					.setIntoQty(BigDecimal.ZERO)
 					.setIntoAmt(BigDecimal.ZERO)
 					.setItemId(inboundItemResponse.getItemId());

+ 487 - 372
src/main/java/com/dk/mdm/service/ivt/InboundSaleReturnService.java

@@ -10,12 +10,18 @@ import com.dk.common.response.ResponseResultVO;
 import com.dk.common.service.BaseService;
 import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
 import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
+import com.dk.mdm.infrastructure.convert.ivt.IntoReturnConvert;
+import com.dk.mdm.infrastructure.convert.ivt.IntoReturnItemConvert;
 import com.dk.mdm.mapper.ivt.InboundItemMapper;
 import com.dk.mdm.mapper.ivt.InboundMapper;
+import com.dk.mdm.mapper.ivt.IntoReturnItemMapper;
+import com.dk.mdm.mapper.ivt.IntoReturnMapper;
 import com.dk.mdm.mapper.pur.PurchaseItemMapper;
 import com.dk.mdm.mapper.pur.PurchaseMapper;
 import com.dk.mdm.model.pojo.ivt.Inbound;
 import com.dk.mdm.model.pojo.ivt.InboundItem;
+import com.dk.mdm.model.pojo.ivt.IntoReturn;
+import com.dk.mdm.model.pojo.ivt.IntoReturnItem;
 import com.dk.mdm.model.pojo.pur.Purchase;
 import com.dk.mdm.model.pojo.pur.PurchaseItem;
 import com.dk.mdm.model.query.ivt.InboundItemQuery;
@@ -23,10 +29,13 @@ import com.dk.mdm.model.query.ivt.InboundQuery;
 import com.dk.mdm.model.query.pur.PurchaseItemQuery;
 import com.dk.mdm.model.response.ivt.InboundItemResponse;
 import com.dk.mdm.model.response.ivt.InboundResponse;
+import com.dk.mdm.model.response.ivt.IntoReturnItemResponse;
+import com.dk.mdm.model.response.ivt.IntoReturnResponse;
 import com.dk.mdm.model.response.pur.PurchaseItemResponse;
 import com.dk.mdm.model.response.pur.PurchaseResponse;
 import com.dk.mdm.model.vo.ivt.InboundItemVO;
 import com.dk.mdm.model.vo.ivt.InboundVO;
+import com.dk.mdm.model.vo.pur.PurchaseVO;
 import com.dk.mdm.service.common.CommonService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -38,382 +47,488 @@ import java.util.Map;
 
 
 /**
- * @desc   : 销售退货入库业务层
- * @date   : 2024/3/7 14:11
  * @author : 寇珊珊
+ * @desc : 销售退货入库业务层
+ * @date : 2024/3/7 14:11
  */
 @Service
 @Transactional
 public class InboundSaleReturnService extends BaseService<Inbound> {
 
-	@Override
-	public BaseMapper<Inbound> getRepository() {
-		return inboundMapper;
-	}
-
-	@Autowired
-	private InboundMapper inboundMapper;
-
-	@Autowired
-	private InboundConvert inboundConvert;
-
-	@Autowired
-	private InboundItemMapper inboundItemMapper;
-
-	@Autowired
-	private InboundItemConvert inboundItemConvert;
-
-	@Autowired
-	private PurchaseMapper purchaseMapper;
-
-	@Autowired
-	private PurchaseItemMapper purchaseItemMapper;
-
-	@Autowired
-	private CommonService commonService;
-
-
-
-	/**
-	 * @desc   : 条件查询
-	 * @date   : 2024/3/7 14:12
-	 * @author : 寇珊珊
-	 */
-	@Pagination
-	public ResponseResultVO<PageList<InboundResponse>> selectInboundAndItem(InboundQuery inboundQuery) {
-		return super.mergeListWithCount(inboundQuery, inboundMapper.selectInboundAndItem(inboundQuery),
-				inboundMapper.selectInboundAndItemCountByCond(inboundQuery));
-	}
-
-
-
-
-	/**
-	 * @desc   : 销售退货入库新建
-	 * @date   : 2024/3/7 14:13
-	 * @author : 寇珊珊
-	 */
-	@Transactional(rollbackFor = {Exception.class})
-	public ResponseResultVO<?> saleReturnInboundInsert(InboundVO inboundVO) {
-		//region  总单
-		//获取 id/单号
-		Map<String , Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUND.getName(),false);
-		inboundVO.setIntoId(codeMap.get("outId").toString()).
-				setIntoNo(codeMap.get("outNote").toString());
-		//入库类型
-		inboundVO.setIntoType(Constant.IntoType.PURRETURN.getName());
-		//入库状态  待入库
-		inboundVO.setIntoStatus(Constant.IntoStatus.DAIRUKU.getName());
-		//退货数量
-		inboundVO.setReturnQty(inboundVO.getIntoingQty());
-		//退货金额
-		inboundVO.setReturnAmt(inboundVO.getIntoingAmt());
-		//实体转换
-		Inbound inbound = inboundConvert.convertToPo(inboundVO);
-		inboundMapper.insert(inbound);
-		//endregion
-
-		//region 明细
-		//校验明细
-		if (inboundVO.getItemList().size() == 0) {
-			return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
-					ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
-		}
-		for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
-			Map<String , Object> map = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUNDITEM.getName(),true);
-			//明细id
-			inboundItemVO.setItemId(map.get("outId").toString());
-			//总单id
-			inboundItemVO.setIntoId(inboundVO.getIntoId());
-			//入库类型
-			inboundItemVO.setIntoType(inboundVO.getIntoType());
-			//入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
-			if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
-				inboundItemVO.setIntoQty(inboundItemVO.getIntoingQty())
-						.setIntoAmt(inboundItemVO.getIntoingAmt());
-			}
-			//成本单价
-			inboundItemVO.setCostPrice(inboundItemVO.getCostPrice());
-			//成本金额
-			inboundItemVO.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP));
-			//库存数量  已入库-出库
-			inboundItemVO.setInvQty(inboundItemVO.getIntoQty().subtract(inboundItemVO.getOutQty()));
-			//入库状态
-			inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
-			//退货数量
-			inboundItemVO.setReturnQty(inboundItemVO.getIntoingQty());
-			//退货金额
-			inboundItemVO.setReturnAmt(inboundItemVO.getIntoingAmt());
-			//实体转换
-			InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
-			inboundItemMapper.insert(inboundItem);
-		}
-		//endregion
-
-		//todo 如果是已入库 调用库存  后续写库存这里补上
-		//region 库存
-
-
-		//endregion
-
-
-		return ResponseResultUtil.success(inboundVO);
-	}
-
-
-	/**
-	 * @desc   : 销售退货入库办理
-	 * @date   : 2024/3/7 15:47
-	 * @author : 寇珊珊
-	 */
-	@Transactional(rollbackFor = {Exception.class})
-	public ResponseResultVO<?> saleReturnHandleInbound(InboundVO inboundVO) {
-		//大编辑标识
-		if (inboundVO.getAllEdit() != null && inboundVO.getAllEdit()) {
-			//region 编辑明细
-			//校验明细
-			if (inboundVO.getItemList().size() == 0) {
-				return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
-						ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
-			}
-			for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
-				if (inboundItemVO.getIntoId() != null) {
-					//编辑明细
-					inboundItemVO.setCostPrice(inboundItemVO.getPriceInto())
-							.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
-							.setIntoQty(inboundItemVO.getIntoingQty())
-							.setIntoAmt(inboundItemVO.getIntoingAmt());
-					//入库状态
-					String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
-					inboundItemVO.setIntoStatus(intoStatus);
-					//实体转换
-					InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
-					//修改
-					inboundItemMapper.updateById(inboundItem);
-				}
-				//endregion
-				//region 新建明细
-				else {
-					Map<String , Object> map = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUNDITEM.getName(),true);
-					inboundItemVO
-							.setItemId(map.get("outId").toString())
-							.setIntoQty(inboundItemVO.getIntoingQty())
-							.setIntoAmt(inboundItemVO.getIntoingAmt())
-							.setIntoId(inboundVO.getIntoId())
-							.setCostPrice(inboundItemVO.getPriceInto())
-							.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
-							.setIntoType(Constant.IntoType.PURRETURN.getName());
-					//入库状态
-					String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
-					inboundItemVO.setIntoStatus(intoStatus);
-					//实体转换
-					InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
-					//新建
-					inboundItemMapper.insert(inboundItem);
-				}
-				//region  销售退货
-				//销售退货明细
-				if(inboundItemVO.getFromItemId()!=null){
-					PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
-					PurchaseItem  purchaseItem = new PurchaseItem();
-					purchaseItem.setItemId(purchaseItemResponse.getItemId());
-					purchaseItem.setIntoingQty(purchaseItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoQty()));
-					purchaseItem.setIntoingAmt(purchaseItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoAmt()));
-					purchaseItem.setIntoQty(purchaseItemResponse.getIntoQty().add(inboundItemVO.getIntoQty()));
-					purchaseItem.setIntoAmt(purchaseItemResponse.getIntoAmt().add(inboundItemVO.getIntoAmt()));
-					//入库状态
-					String intoStatus = this.setIntoStatus(purchaseItem.getIntoingQty(), purchaseItem.getIntoQty());
-					purchaseItem.setIntoStatus(intoStatus);
-					purchaseItemMapper.updateById(purchaseItem);
-				}
-				//endregion
-			}
-			//endregion
-
-			//region 删除明细
-			BigDecimal sumDelIntoQty = BigDecimal.ZERO;
-			BigDecimal sumDelIntoAmt = BigDecimal.ZERO;
-			if (inboundVO.getDeleteItemList() != null) {
-				 sumDelIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-				 sumDelIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
-				for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
-					if (inboundItemVO.getItemId() != null) {
-						InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
-						inboundItem.setFlgValid(false);
-						inboundItemMapper.updateById(inboundItem);
-					}
-					//region  销售退货
-					if(inboundVO.getFromId()!=null){
-						//region 销售退货订单明细
-						List<PurchaseItemResponse> purchaseItemResponses = purchaseItemMapper.selectByCond(new PurchaseItemQuery().setPurId(inboundVO.getFromId()));
-						for (PurchaseItemResponse purchaseItemResponse : purchaseItemResponses) {
-							PurchaseItem  purchaseItem = new PurchaseItem();
-							purchaseItem.setItemId(purchaseItemResponse.getItemId());
-							purchaseItem.setIntoingQty(purchaseItemResponse.getIntoingQty().add(purchaseItemResponse.getIntoQty()));
-							purchaseItem.setIntoingAmt(purchaseItemResponse.getIntoingAmt().add(purchaseItemResponse.getIntoAmt()));
-							purchaseItem.setIntoQty(BigDecimal.ZERO);
-							purchaseItem.setIntoingAmt(BigDecimal.ZERO);
-							//入库状态
-							String intoStatus = this.setIntoStatus(purchaseItem.getIntoingQty(), purchaseItem.getIntoQty());
-							purchaseItem.setIntoStatus(intoStatus);
-							purchaseItemMapper.updateById(purchaseItem);
-						}
-						//endregion
-					}
-					//endregion
-
-				}
-			}
-			//endregion
-
-			//region 编辑总单
-			BigDecimal sumIntoQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-			BigDecimal sumIntoAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
-			inboundVO.setIntoQty(sumIntoQty);
-			inboundVO.setIntoAmt(sumIntoAmt);
-			//已入库数量==入库中数量   入库完成
-			if(sumIntoQty.compareTo(inboundVO.getIntoQty())==0){
-				//已入库
-				inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
-			} else {
-				//入库中
-				inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
-			}
-			//实体转换
-			Inbound inbound = inboundConvert.convertToPo(inboundVO);
-			//修改
-			super.update(inbound);
-			//endregion
-
-			//region  修改销售退货订单
-			if(inboundVO.getFromId()!=null){
-				PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
-				Purchase  purchase = new Purchase();
-				purchase.setPurId(purchaseResponse.getPurId());
-				purchase.setIntoQty(purchaseResponse.getIntoQty().subtract(sumIntoQty.add(sumDelIntoQty)));
-				purchase.setIntoAmt(purchaseResponse.getIntoAmt().subtract(sumIntoAmt.add(sumDelIntoAmt)));
-				purchase.setIntoingQty(purchaseResponse.getIntoingQty().add(sumIntoQty).subtract(sumDelIntoQty));
-				purchase.setIntoingAmt(purchaseResponse.getIntoingAmt().add(sumIntoAmt).subtract(sumDelIntoAmt));
-				//入库状态
-				String intoStatus = this.setIntoStatus(purchase.getIntoingQty(), purchase.getIntoQty());
-				purchase.setIntoStatus(intoStatus);
-				//修改
-				purchaseMapper.updateById(purchase);
-			}
-			//endregion
-
-			//todo 如果是已入库 调用库存  后续写库存这里补上
-			//region 修改库存
-
-			//endregion
-		}
-		return ResponseResultUtil.success(inboundVO);
-	}
-
-
-	/**
-	 * @desc   : 销售退货入库撤销
-	 * @date   : 2024/3/7 17:06
-	 * @author : 寇珊珊
-	 */
-	@Transactional(rollbackFor = {Exception.class})
-	public ResponseResultVO<?> saleReturnInboundCancel(InboundVO inboundVO) {
-		//region 查询入库总单数据信息
-		InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
-		//endregion
-
-		//region 修改订单数据信息
-		if (inboundVO.getFromId() != null) {
-			PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundResponse.getFromId());
-			Purchase purchase = new Purchase();
-			purchase.setPurId(inboundResponse.getFromId());
-			purchase.setIntoQty(purchaseResponse.getIntoQty().subtract(inboundResponse.getIntoQty()));
-			purchase.setIntoAmt(purchaseResponse.getIntoAmt().subtract(inboundResponse.getIntoAmt()));
-			purchase.setIntoingQty(purchaseResponse.getIntoingQty().add(inboundResponse.getIntoQty()));
-			purchase.setIntoingAmt(purchaseResponse.getIntoingAmt().add(inboundResponse.getIntoAmt()));
-			//入库状态
-			String intoStatus = this.setIntoStatus(purchase.getIntoingQty(), purchase.getIntoQty());
-			purchase.setIntoStatus(intoStatus);
-			purchaseMapper.updateById(purchase);
-		}
-		//endregion
-
-		//region 修改总单数据信息
-		Inbound inbound = new Inbound();
-		inbound.setIntoId(inboundVO.getIntoId());
-		inbound.setIntoDate(null);
-		inbound.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
-		inbound.setIntoQty(BigDecimal.ZERO);
-		inbound.setIntoAmt(BigDecimal.ZERO);
-		inboundMapper.updateById(inbound);
-		//endregion
-
-		//region 明细数据
-		//根据总单id查明细
-		List<InboundItemResponse> orderEntryItemResponsesList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inbound.getIntoId()));
-		for (InboundItemResponse inboundItemResponse : orderEntryItemResponsesList) {
-			//region 修改销售退货明细数据信息
-			if(inboundItemResponse.getFromItemId()!=null){
-				//查询
-				PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemResponse.getFromItemId());
-				PurchaseItem  purchaseItem = new PurchaseItem();
-				purchaseItem.setItemId(purchaseItemResponse.getItemId());
-				purchaseItem.setIntoQty(purchaseItemResponse.getIntoQty().subtract(inboundItemResponse.getIntoQty()));
-				purchaseItem.setIntoAmt(purchaseItemResponse.getIntoAmt().subtract(inboundItemResponse.getIntoAmt()));
-				purchaseItem.setIntoingQty(purchaseItemResponse.getIntoingQty().add(inboundItemResponse.getIntoQty()));
-				purchaseItem.setIntoingAmt(purchaseItemResponse.getIntoingAmt().add(inboundItemResponse.getIntoAmt()));
-				//入库状态
-				String intoStatusItem = this.setIntoStatus(purchaseItem.getIntoingQty(), purchaseItem.getIntoQty());
-				purchaseItem.setIntoStatus(intoStatusItem);
-			}
-			//endregion
-
-			//region修改入库明细信息
-			InboundItem inboundItem = new InboundItem();
-			inboundItem.setIntoId(inbound.getIntoId())
-					.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
-					.setIntoQty(BigDecimal.ZERO)
-					.setIntoAmt(BigDecimal.ZERO)
-					.setItemId(inboundItemResponse.getItemId());
-			inboundItemMapper.updateById(inboundItem);
-			//endregion
-		}
-		//endregion
-
-
-		//todo 调用库存  后续写库存这里补上
-		//region 修改库存
-
-		//endregion
-
-		return ResponseResultUtil.success();
-	}
-
-
-	/**
-	 * @desc : 入库状态通用(目前本页面)
-	 * @date : 2024/3/9 8:59
-	 * @author : 寇珊珊
-	 */
-	public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty) {
-		//入库状态
-		String intoStatus = null;
-		//已入库数量=0 入库中数量>0
-		if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) {
-			//入库中
-			intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
-		}
-		//已入库数量=0 入库中数量=0
-		else if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) {
-			//待入库
-			intoStatus = Constant.IntoStatus.DAIRUKU.getName();
-		}
-		//已入库数量>0 入库中数量>0
-		else if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) {
-			//入库中
-			intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
-		}
-		return intoStatus;
-	}
-	
+    @Override
+    public BaseMapper<Inbound> getRepository() {
+        return inboundMapper;
+    }
+
+    @Autowired
+    private InboundMapper inboundMapper;
+
+    @Autowired
+    private InboundConvert inboundConvert;
+
+    @Autowired
+    private InboundItemMapper inboundItemMapper;
+
+    @Autowired
+    private InboundItemConvert inboundItemConvert;
+
+    @Autowired
+    private PurchaseMapper purchaseMapper;
+
+    @Autowired
+    private PurchaseItemMapper purchaseItemMapper;
+
+    @Autowired
+    private IntoReturnMapper intoReturnMapper;
+
+    @Autowired
+    private IntoReturnConvert intoReturnConvert;
+
+    @Autowired
+    private IntoReturnItemMapper intoReturnItemMapper;
+
+    @Autowired
+    private IntoReturnItemConvert intoReturnItemConvert;
+
+
+    @Autowired
+    private CommonService commonService;
+
+
+    /**
+     * @desc : 条件查询
+     * @date : 2024/3/7 14:12
+     * @author : 寇珊珊
+     */
+    @Pagination
+    public ResponseResultVO<PageList<InboundResponse>> selectInboundAndItem(InboundQuery inboundQuery) {
+        return super.mergeListWithCount(inboundQuery, inboundMapper.selectInboundAndItem(inboundQuery),
+                inboundMapper.selectInboundAndItemCountByCond(inboundQuery));
+    }
+
+
+    /**
+     * @desc : 销售退货入库新建
+     * @date : 2024/3/7 14:13
+     * @author : 寇珊珊
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> saleReturnInboundInsert(InboundVO inboundVO) {
+        //region  总单
+        //获取 id/单号
+        Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUND.getName(), false);
+        inboundVO.setIntoId(codeMap.get("outId").toString()).
+                setIntoNo(codeMap.get("outNote").toString());
+        //入库类型
+        inboundVO.setIntoType(Constant.IntoType.PURRETURN.getName());
+        //自动入库标识
+        if (inboundVO.getAutomaticFlg()) {
+            //已入库
+            inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
+        } else {
+            //入库中
+            inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
+        }
+        //退货数量
+        inboundVO.setReturnQty(inboundVO.getIntoingQty());
+        //退货金额
+        inboundVO.setReturnAmt(inboundVO.getIntoingAmt());
+        //入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
+        if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
+            inboundVO.setIntoQty(inboundVO.getIntoingQty())
+                    .setIntoAmt(inboundVO.getIntoingAmt())
+                    .setIntoingQty(BigDecimal.ZERO)
+                    .setIntoingAmt(BigDecimal.ZERO)
+            ;
+        }
+
+        //实体转换
+        Inbound inbound = inboundConvert.convertToPo(inboundVO);
+        inboundMapper.insert(inbound);
+        //endregion
+
+        //region 销售退货
+        if (inboundVO.getFromId() != null) {
+            IntoReturn intoReturn = new IntoReturn();
+            IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
+            intoReturn.setReturnId(inboundVO.getFromId());
+            intoReturn.setOutingQty(intoReturnResponse.getOutingQty().subtract(inboundVO.getIntoingQty()));
+            intoReturn.setOutingAmt(intoReturnResponse.getOutingAmt().subtract(inboundVO.getIntoingAmt()));
+            intoReturn.setOutQty(intoReturnResponse.getOutQty().add(inboundVO.getIntoAmt()));
+            intoReturn.setOutAmt(intoReturnResponse.getOutAmt().add(inboundVO.getIntoQty()));
+            //出库状态
+            String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
+            intoReturn.setOutStatus(outStatus);
+            //修改
+            intoReturnMapper.updateById(intoReturn);
+        }
+        //endregion
+
+
+        //region 明细
+        //校验明细
+        if (inboundVO.getItemList().size() == 0) {
+            return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
+                    ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
+        }
+        for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
+            //region  明细
+            Map<String, Object> map = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUNDITEM.getName(), true);
+            //明细id
+            inboundItemVO.setItemId(map.get("outId").toString());
+            //总单id
+            inboundItemVO.setIntoId(inboundVO.getIntoId());
+            //入库类型
+            inboundItemVO.setIntoType(inboundVO.getIntoType());
+            //入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
+            if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
+                inboundItemVO.setIntoQty(inboundItemVO.getIntoingQty())
+                        .setIntoAmt(inboundItemVO.getIntoingAmt());
+            }
+            //成本单价
+            inboundItemVO.setCostPrice(inboundItemVO.getCostPrice());
+            //成本金额
+            inboundItemVO.setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP));
+            //库存数量  已入库-出库
+            inboundItemVO.setInvQty(inboundItemVO.getIntoQty().subtract(inboundItemVO.getOutQty()));
+            //入库状态
+            inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
+            //退货数量
+            inboundItemVO.setReturnQty(inboundItemVO.getIntoingQty());
+            //退货金额
+            inboundItemVO.setReturnAmt(inboundItemVO.getIntoingAmt());
+            //实体转换
+            InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+            inboundItemMapper.insert(inboundItem);
+            //endregion
+
+            //region 销售退货明细
+            if (inboundItemVO.getFromItemId() != null) {
+                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
+                IntoReturnItem intoReturnItem = new IntoReturnItem();
+                intoReturnItem.setItemId(inboundItemVO.getFromItemId());
+                intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().add(inboundItemVO.getIntoQty()));
+                intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().add(inboundItemVO.getIntoAmt()));
+                intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().add(inboundItemVO.getIntoingQty()));
+                intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().add(inboundItemVO.getIntoingAmt()));
+                //出库状态
+                String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
+                intoReturnItem.setOutStatus(outStatus);
+                //修改
+                intoReturnItemMapper.updateById(intoReturnItem);
+            }
+            //endregion
+
+        }
+        //endregion
+
+        //todo 如果是已入库 调用库存  后续写库存这里补上
+        //region 库存
+
+
+        //endregion
+
+
+        return ResponseResultUtil.success(inboundVO);
+    }
+
+
+    /**
+     * @desc : 销售退货入库办理
+     * @date : 2024/3/7 15:47
+     * @author : 寇珊珊
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> saleReturnHandleInbound(InboundVO inboundVO) {
+        //大编辑标识
+        if (inboundVO.getAllEdit() != null && inboundVO.getAllEdit()) {
+            //region 编辑明细
+            //校验明细
+            if (inboundVO.getItemList().size() == 0) {
+                return ResponseResultUtil.error(ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getCode(),
+                        ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
+            }
+            for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
+                if (inboundItemVO.getIntoId() != null) {
+                    //编辑明细
+                    inboundItemVO.setCostPrice(inboundItemVO.getPriceInto())
+                            .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                            .setIntoQty(inboundItemVO.getIntoingQty())
+                            .setIntoAmt(inboundItemVO.getIntoingAmt());
+                    //入库状态
+                    String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
+                    inboundItemVO.setIntoStatus(intoStatus);
+                    //实体转换
+                    InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                    //修改
+                    inboundItemMapper.updateById(inboundItem);
+                }
+                //endregion
+                //region 新建明细
+                else {
+                    Map<String, Object> map = commonService.getUniqueNoteCode(Constant.docNameConstant.OTHERINBOUNDITEM.getName(), true);
+                    inboundItemVO
+                            .setItemId(map.get("outId").toString())
+                            .setIntoQty(inboundItemVO.getIntoingQty())
+                            .setIntoAmt(inboundItemVO.getIntoingAmt())
+                            .setIntoId(inboundVO.getIntoId())
+                            .setCostPrice(inboundItemVO.getPriceInto())
+                            .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                            .setIntoType(Constant.IntoType.PURRETURN.getName());
+                    //入库状态
+                    String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
+                    inboundItemVO.setIntoStatus(intoStatus);
+                    //实体转换
+                    InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                    //新建
+                    inboundItemMapper.insert(inboundItem);
+                }
+                //endregion
+
+                //region  销售退货明细
+                if (inboundItemVO.getFromItemId() != null) {
+                    IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
+                    IntoReturnItem intoReturnItem = new IntoReturnItem();
+                    intoReturnItem.setItemId(inboundItemVO.getFromItemId());
+                    intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().add(inboundItemVO.getIntoQty()));
+                    intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().add(inboundItemVO.getIntoAmt()));
+                    intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().add(inboundItemVO.getIntoingQty()));
+                    intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().add(inboundItemVO.getIntoingAmt()));
+                    //出库状态
+                    String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
+                    intoReturnItem.setOutStatus(outStatus);
+                    //修改
+                    intoReturnItemMapper.updateById(intoReturnItem);
+                }
+                //endregion
+            }
+            //endregion
+
+            //region 删除明细
+            BigDecimal sumDelOutQty = BigDecimal.ZERO;
+            BigDecimal sumDelOutAmt = BigDecimal.ZERO;
+            BigDecimal sumDelOutingQty = BigDecimal.ZERO;
+            BigDecimal sumDelOutingAmt = BigDecimal.ZERO;
+            if (inboundVO.getDeleteItemList() != null) {
+                sumDelOutQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                sumDelOutAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+                sumDelOutingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                sumDelOutingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+                for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
+                    if (inboundItemVO.getItemId() != null) {
+                        InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                        inboundItem.setFlgValid(false);
+                        inboundItemMapper.updateById(inboundItem);
+                    }
+                    //region  销售退货明细
+                    if (inboundItemVO.getFromItemId() != null) {
+                        //region 销售退货订单明细
+                        IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
+                        IntoReturnItem intoReturnItem = new IntoReturnItem();
+                        intoReturnItem.setItemId(inboundItemVO.getFromItemId());
+                        intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().subtract(inboundItemVO.getIntoQty()));
+                        intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().subtract(inboundItemVO.getIntoAmt()));
+                        intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().subtract(inboundItemVO.getIntoingQty()));
+                        intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().subtract(inboundItemVO.getIntoingAmt()));
+                        //出库状态
+                        String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
+                        intoReturnItem.setOutStatus(outStatus);
+                        //修改
+                        intoReturnItemMapper.updateById(intoReturnItem);
+                        //endregion
+                    }
+                    //endregion
+
+                }
+            }
+            //endregion
+
+            //region 编辑总单
+            BigDecimal sumOutQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+            BigDecimal sumOutAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+            BigDecimal sumOutingQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+            BigDecimal sumOutingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+            inboundVO.setIntoQty(sumOutQty);
+            inboundVO.setIntoAmt(sumOutAmt);
+            inboundVO.setIntoingQty(sumOutingQty);
+            inboundVO.setIntoAmt(sumOutingAmt);
+            //已入库数量==入库中数量   入库完成
+            if (inboundVO.getIntoQty().compareTo(inboundVO.getIntoingQty()) == 0) {
+                //已入库
+                inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
+            } else {
+                //入库中
+                inboundVO.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
+            }
+            //实体转换
+            Inbound inbound = inboundConvert.convertToPo(inboundVO);
+            //修改
+            inboundMapper.updateById(inbound);
+            //endregion
+
+            //region  修改销售退货订单
+            if (inboundVO.getFromId() != null) {
+                IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
+                IntoReturn intoReturn = new IntoReturn();
+                intoReturn.setReturnId(inboundVO.getFromId());
+                intoReturn.setOutQty(intoReturnResponse.getOutQty().add(sumOutQty).subtract(sumDelOutQty));
+                intoReturn.setOutAmt(intoReturnResponse.getOutAmt().add(sumOutAmt).subtract(sumDelOutAmt));
+                intoReturn.setOutingQty(intoReturnResponse.getOutingQty().subtract(sumOutQty).subtract(sumDelOutingQty));
+                intoReturn.setOutingAmt(intoReturnResponse.getOutingAmt().subtract(sumOutAmt).subtract(sumDelOutingAmt));
+                //入库状态
+                String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
+                intoReturn.setOutStatus(outStatus);
+                //修改
+                intoReturnMapper.updateById(intoReturn);
+            }
+            //endregion
+
+            //todo 如果是已入库 调用库存  后续写库存这里补上
+            //region 修改库存
+
+            //endregion
+        }
+        return ResponseResultUtil.success(inboundVO);
+    }
+
+
+    /**
+     * @desc : 销售退货入库撤销
+     * @date : 2024/3/7 17:06
+     * @author : 寇珊珊
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> saleReturnInboundCancel(InboundVO inboundVO) {
+        //region 查询入库总单数据信息
+        InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
+        //endregion
+
+        //region 修改订单数据信息
+        if (inboundVO.getFromId() != null) {
+            //查询
+            IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
+            //赋值
+            IntoReturn intoReturn = new IntoReturn();
+            intoReturn.setReturnId(inboundVO.getFromId());
+            intoReturn.setOutQty(intoReturnResponse.getOutQty().add(inboundResponse.getIntoQty()));
+            intoReturn.setOutAmt(intoReturnResponse.getOutAmt().add(inboundResponse.getIntoAmt()));
+            intoReturn.setOutingQty(intoReturnResponse.getOutingQty().subtract(inboundResponse.getIntoQty()));
+            intoReturn.setOutingAmt(intoReturnResponse.getOutingAmt().subtract(inboundResponse.getIntoAmt()));
+            //出库状态
+            String outStatus = this.setOutStatus(intoReturn.getOutingQty(), intoReturn.getOutQty());
+            intoReturn.setOutStatus(outStatus);
+            //修改
+            intoReturnMapper.updateById(intoReturn);
+        }
+        //endregion
+
+        //region 修改总单数据信息
+        Inbound inbound = new Inbound();
+        inbound.setIntoId(inboundVO.getIntoId());
+        inbound.setIntoDate(null);
+        inbound.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName());
+        inbound.setIntoQty(BigDecimal.ZERO);
+        inbound.setIntoAmt(BigDecimal.ZERO);
+        inboundMapper.updateById(inbound);
+        //endregion
+
+        //region 明细数据
+        //根据总单id查明细
+        List<InboundItemResponse> orderEntryItemResponsesList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inbound.getIntoId()));
+        for (InboundItemResponse inboundItemResponse : orderEntryItemResponsesList) {
+            //region 修改销售退货明细数据信息
+            if (inboundItemResponse.getFromItemId() != null) {
+                //查询
+                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemResponse.getFromItemId());
+                IntoReturnItem intoReturnItem = new IntoReturnItem();
+                intoReturnItem.setItemId(inboundItemResponse.getFromItemId());
+                intoReturnItem.setOutQty(intoReturnItemResponse.getOutQty().subtract(inboundItemResponse.getIntoQty()));
+                intoReturnItem.setOutAmt(intoReturnItemResponse.getOutAmt().subtract(inboundItemResponse.getIntoAmt()));
+                intoReturnItem.setOutingQty(intoReturnItemResponse.getOutingQty().add(inboundItemResponse.getIntoQty()));
+                intoReturnItem.setOutingAmt(intoReturnItemResponse.getOutingAmt().add(inboundItemResponse.getIntoAmt()));
+                //出库状态
+                String outStatus = this.setOutStatus(intoReturnItem.getOutingQty(), intoReturnItem.getOutQty());
+                intoReturnItem.setOutStatus(outStatus);
+                //修改
+                intoReturnItemMapper.updateById(intoReturnItem);
+            }
+            //endregion
+
+            //region修改入库明细信息
+            InboundItem inboundItem = new InboundItem();
+            inboundItem.setIntoId(inbound.getIntoId())
+                    .setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
+                    .setIntoingQty(inboundItemResponse.getIntoingQty().add(inboundItemResponse.getIntoQty()))
+                    .setIntoingAmt(inboundItemResponse.getIntoingAmt().add(inboundItemResponse.getIntoAmt()))
+                    .setIntoQty(BigDecimal.ZERO)
+                    .setIntoAmt(BigDecimal.ZERO)
+                    .setItemId(inboundItemResponse.getItemId());
+            inboundItemMapper.updateById(inboundItem);
+            //endregion
+        }
+        //endregion
+
+
+        //todo 调用库存  后续写库存这里补上
+        //region 修改库存
+
+        //endregion
+
+        return ResponseResultUtil.success();
+    }
+
+
+    /**
+     * @desc : 入库状态通用(目前本页面)
+     * @date : 2024/3/9 8:59
+     * @author : 寇珊珊
+     */
+    public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty) {
+        //入库状态
+        String intoStatus = null;
+        //已入库数量=0 入库中数量>0
+        if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) {
+            //入库中
+            intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
+        }
+        //已入库数量=0 入库中数量=0
+        else if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) {
+            //待入库
+            intoStatus = Constant.IntoStatus.DAIRUKU.getName();
+        }
+        //已入库数量>0 入库中数量>0
+        else if (intoQty.compareTo(BigDecimal.ZERO) > 0 && intoingQty.compareTo(BigDecimal.ZERO) > 0) {
+            //入库中
+            intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
+        }
+        return intoStatus;
+    }
+
+
+    /**
+     * @desc : 出库状态通用(目前本页面)
+     * @date : 2024/3/9 8:59
+     * @author : 寇珊珊
+     */
+    public String setOutStatus(BigDecimal outingQty, BigDecimal outQty) {
+        //入库状态
+        String outStatus = null;
+        //已入库数量=0 入库中数量>0
+        if (outQty.compareTo(BigDecimal.ZERO) == 0 && outingQty.compareTo(BigDecimal.ZERO) > 0) {
+            //入库中
+            outStatus = Constant.OutStatus.CHUKUZHONG.getName();
+        }
+        //已入库数量=0 入库中数量=0
+        else if (outQty.compareTo(BigDecimal.ZERO) == 0 && outingQty.compareTo(BigDecimal.ZERO) == 0) {
+            //待入库
+            outStatus = Constant.OutStatus.DAICHUKU.getName();
+        }
+        //已入库数量>0 入库中数量>0
+        else if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) > 0) {
+            //入库中
+            outStatus = Constant.OutStatus.YICHUKU.getName();
+        }
+        return outStatus;
+    }
+
 }

+ 93 - 92
src/main/java/com/dk/mdm/service/ivt/IntoReturnService.java

@@ -108,96 +108,96 @@ public class IntoReturnService extends BaseService<IntoReturn> {
             rollbackFor = {Exception.class}
     )
     public ResponseResultVO<?> insert(IntoReturnVO intoReturnVO) {
-            //校验明细长度
-            List<IntoReturnItemVO> intoReturnItemVOList = intoReturnVO.getIntoReturnItemVOList();
-            //明细不存在
-            if (intoReturnItemVOList == null || intoReturnItemVOList.size() == 0) {
-                //返回 采购退货明细不可为空,请重新操作
-                return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PURCHASE_RETURN_DETAIL_NOT_EXIST.getMessage());
-            }
-            //查询采购订单
-            PurchaseResponse purchaseResponse = purchaseMapper.selectById(intoReturnVO.getPurId());
-            //设置总单
-            intoReturnVO = this.insertTotal(intoReturnVO, purchaseResponse);
-            //设置明细
-            intoReturnItemVOList = this.insertDetail(intoReturnVO, intoReturnItemVOList);
-
-
-            //反写采购订单已入库退货数量、金额
-            purchaseMapper.updateAmount(new Purchase().setPurId(intoReturnVO.getPurId())
-                    .setReturnQty(purchaseResponse.getReturnQty().add(intoReturnVO.getSumQuantity()))
-                    .setReturnAmt(purchaseResponse.getReturnAmt().add(intoReturnVO.getSumAmount()))
+        //校验明细长度
+        List<IntoReturnItemVO> intoReturnItemVOList = intoReturnVO.getIntoReturnItemVOList();
+        //明细不存在
+        if (intoReturnItemVOList == null || intoReturnItemVOList.size() == 0) {
+            //返回 采购退货明细不可为空,请重新操作
+            return ResponseResultUtil.error(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.PURCHASE_RETURN_DETAIL_NOT_EXIST.getMessage());
+        }
+        //查询采购订单
+        PurchaseResponse purchaseResponse = purchaseMapper.selectById(intoReturnVO.getPurId());
+        //设置总单
+        intoReturnVO = this.insertTotal(intoReturnVO, purchaseResponse);
+        //设置明细
+        intoReturnItemVOList = this.insertDetail(intoReturnVO, intoReturnItemVOList);
+
+
+        //反写采购订单已入库退货数量、金额
+        purchaseMapper.updateAmount(new Purchase().setPurId(intoReturnVO.getPurId())
+                .setReturnQty(purchaseResponse.getReturnQty().add(intoReturnVO.getSumQuantity()))
+                .setReturnAmt(purchaseResponse.getReturnAmt().add(intoReturnVO.getSumAmount()))
+        );
+        BigDecimal sumReturnQty = BigDecimal.ZERO;
+        BigDecimal sumReturnAmt = BigDecimal.ZERO;
+        //反写入库订单明细、反写订单明细
+        for (IntoReturnItemVO intoReturnItemVO : intoReturnItemVOList) {
+
+            //根据退货明细中入库明细id查询入库明细数据
+            InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(intoReturnItemVO.getIntoItemId());
+            BigDecimal returnQty = inboundItemResponse.getReturnQty().add(intoReturnItemVO.getItemQty().setScale(6, BigDecimal.ROUND_HALF_UP));
+            BigDecimal returnAmt = inboundItemResponse.getReturnAmt().add(intoReturnItemVO.getItemAmt().setScale(6, BigDecimal.ROUND_HALF_UP));
+            sumReturnQty = sumReturnQty.add(returnQty);
+            sumReturnAmt = sumReturnAmt.add(returnAmt);
+            inboundItemMapper.updateAmount(
+                    new InboundItem()
+                            .setItemId(inboundItemResponse.getItemId())
+                            .setReturnQty(returnQty)
+                            .setReturnAmt(returnAmt)
             );
-            BigDecimal sumReturnQty = BigDecimal.ZERO;
-            BigDecimal sumReturnAmt = BigDecimal.ZERO;
-            //反写入库订单明细、反写订单明细
-            for (IntoReturnItemVO intoReturnItemVO : intoReturnItemVOList) {
-
-                //根据退货明细中入库明细id查询入库明细数据
-                InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(intoReturnItemVO.getIntoItemId());
-                BigDecimal returnQty = inboundItemResponse.getReturnQty().add(intoReturnItemVO.getItemQty().setScale(6, BigDecimal.ROUND_HALF_UP));
-                BigDecimal returnAmt = inboundItemResponse.getReturnAmt().add(intoReturnItemVO.getItemAmt().setScale(6, BigDecimal.ROUND_HALF_UP));
-                sumReturnQty = sumReturnQty.add(returnQty);
-                sumReturnAmt = sumReturnAmt.add(returnAmt);
-                inboundItemMapper.updateAmount(
-                        new InboundItem()
-                                .setItemId(inboundItemResponse.getItemId())
-                                .setReturnQty(returnQty)
-                                .setReturnAmt(returnAmt)
-                );
-                //TODO 反写订单出库明细 退货数量和退货金额
-                //查询采购订单明细数据
-                PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(intoReturnItemVO.getPurItemId());
-                //反写订单明细退货数量和退货金额
-                purchaseItemMapper.updateAmount(
-                        new PurchaseItem()
-                                .setItemId(intoReturnItemVO.getPurItemId())
-                                .setReturnQty(purchaseItemResponse.getReturnQty().add(intoReturnItemVO.getItemQty().setScale(6, BigDecimal.ROUND_HALF_UP)))
-                                .setReturnAmt(purchaseItemResponse.getReturnAmt().add(intoReturnItemVO.getItemAmt().setScale(6, BigDecimal.ROUND_HALF_UP)))
-
-                );
-            }
-            //反写入库单退货数量金额 todo
-            InboundResponse inboundResponse = inboundMapper.selectById(intoReturnVO.getIntoId());
-            inboundMapper.updateAmount(new Inbound().setIntoId(intoReturnVO.getIntoId())
-                    .setReturnQty(inboundResponse.getReturnQty().add(sumReturnQty))
-                    .setReturnAmt(inboundResponse.getReturnAmt().add(sumReturnAmt)));
-            //新建出库单
-            OutboundVO outboundVO = new OutboundVO();
-            //来源ID
-            outboundVO.setFromId(intoReturnVO.getReturnId());
-            //来源单号
-            outboundVO.setFromNo(intoReturnVO.getReturnNo());
-            //部门
-            outboundVO.setOrgId(intoReturnVO.getOrgId());
-            //员工
-            outboundVO.setStaffId(intoReturnVO.getStaffId());
-            //出库状态 待出库
-            outboundVO.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
-            //供应商
-            outboundVO.setSupId(intoReturnVO.getSupId());
-            outboundVO.setMakeStaff(authUtils.getStaff().getStaffId());
-            outboundVO.setCpId(authUtils.getStaff().getCpId());
-
-            outboundVO.setFromId(intoReturnVO.getReturnId());
-            List<OutboundItemVO> itemList = new ArrayList<>();
-            Integer itemIndex = 0;
-            for (IntoReturnItemVO intoReturnItemVO : intoReturnItemVOList) {
-                //来源单ID 入库退货
-                OutboundItemVO outboundItemVO = new OutboundItemVO();
-
-                outboundItemVO.setFromId(intoReturnItemVO.getReturnId());
-                outboundItemVO.setFromItemId(intoReturnItemVO.getItemId());
-                outboundItemVO.setSkuId(intoReturnItemVO.getSkuId());
-                outboundItemVO.setItemIndex(itemIndex + 1);
-                outboundItemVO.setPriceOut(intoReturnItemVO.getPriceReturn());
-                outboundItemVO.setInvId(intoReturnItemVO.getInvId());
-                itemList.add(outboundItemVO);
-            }
+            //TODO 反写订单出库明细 退货数量和退货金额
+            //查询采购订单明细数据
+            PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(intoReturnItemVO.getPurItemId());
+            //反写订单明细退货数量和退货金额
+            purchaseItemMapper.updateAmount(
+                    new PurchaseItem()
+                            .setItemId(intoReturnItemVO.getPurItemId())
+                            .setReturnQty(purchaseItemResponse.getReturnQty().add(intoReturnItemVO.getItemQty().setScale(6, BigDecimal.ROUND_HALF_UP)))
+                            .setReturnAmt(purchaseItemResponse.getReturnAmt().add(intoReturnItemVO.getItemAmt().setScale(6, BigDecimal.ROUND_HALF_UP)))
 
-            outboundVO.setItemList(itemList);
-            //新建出库单
-            outboundService.insertOutBound(outboundVO);
+            );
+        }
+        //反写入库单退货数量金额 todo
+        InboundResponse inboundResponse = inboundMapper.selectById(intoReturnVO.getIntoId());
+        inboundMapper.updateAmount(new Inbound().setIntoId(intoReturnVO.getIntoId())
+                .setReturnQty(inboundResponse.getReturnQty().add(sumReturnQty))
+                .setReturnAmt(inboundResponse.getReturnAmt().add(sumReturnAmt)));
+        //新建出库单
+        OutboundVO outboundVO = new OutboundVO();
+        //来源ID
+        outboundVO.setFromId(intoReturnVO.getReturnId());
+        //来源单号
+        outboundVO.setFromNo(intoReturnVO.getReturnNo());
+        //部门
+        outboundVO.setOrgId(intoReturnVO.getOrgId());
+        //员工
+        outboundVO.setStaffId(intoReturnVO.getStaffId());
+        //出库状态 待出库
+        outboundVO.setOutStatus(Constant.OutStatus.DAICHUKU.getName());
+        //供应商
+        outboundVO.setSupId(intoReturnVO.getSupId());
+        outboundVO.setMakeStaff(authUtils.getStaff().getStaffId());
+        outboundVO.setCpId(authUtils.getStaff().getCpId());
+
+        outboundVO.setFromId(intoReturnVO.getReturnId());
+        List<OutboundItemVO> itemList = new ArrayList<>();
+        Integer itemIndex = 0;
+        for (IntoReturnItemVO intoReturnItemVO : intoReturnItemVOList) {
+            //来源单ID 入库退货
+            OutboundItemVO outboundItemVO = new OutboundItemVO();
+
+            outboundItemVO.setFromId(intoReturnItemVO.getReturnId());
+            outboundItemVO.setFromItemId(intoReturnItemVO.getItemId());
+            outboundItemVO.setSkuId(intoReturnItemVO.getSkuId());
+            outboundItemVO.setItemIndex(itemIndex + 1);
+            outboundItemVO.setPriceOut(intoReturnItemVO.getPriceReturn());
+            outboundItemVO.setInvId(intoReturnItemVO.getInvId());
+            itemList.add(outboundItemVO);
+        }
+
+        outboundVO.setItemList(itemList);
+        //新建出库单
+        outboundService.insertOutBound(outboundVO);
 
         return ResponseResultUtil.success();
     }
@@ -269,11 +269,12 @@ public class IntoReturnService extends BaseService<IntoReturn> {
             intoReturnItemVO.setItemAmt(intoReturnItemVO.getItemQty().multiply(intoReturnItemVO.getPriceReturn()).setScale(2, BigDecimal.ROUND_HALF_UP));
             //自动]出库赋值  已入库数量、已入库金额
             if (intoReturnVO.getFlgAutoIvt()) {
+                intoReturnItemVO.setOutQty(intoReturnItemVO.getItemQty().abs());
+                intoReturnItemVO.setOutAmt(intoReturnItemVO.getItemAmt().abs());
 
-                intoReturnItemVO.setIntoQty(intoReturnItemVO.getItemQty().abs());
-
-                intoReturnItemVO.setIntoAmt(intoReturnItemVO.getItemAmt().abs());
-
+            }else{
+                intoReturnItemVO.setOutingQty(intoReturnItemVO.getItemQty().abs());
+                intoReturnItemVO.setOutingAmt(intoReturnItemVO.getItemAmt().abs());
             }
             //新建明细
             IntoReturnItem intoReturnItem = intoReturnItemConvert.convertToPo(intoReturnItemVO);

+ 288 - 6
src/main/java/com/dk/mdm/service/mst/CusFollowService.java

@@ -1,23 +1,305 @@
 package com.dk.mdm.service.mst;
 
+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.ResponseResultUtil;
+import com.dk.common.response.ResponseResultVO;
+import com.dk.mdm.infrastructure.convert.mst.CusFollowConvert;
+import com.dk.mdm.infrastructure.util.AuthUtils;
+import com.dk.mdm.mapper.mst.CusFollowStaffMapper;
+import com.dk.mdm.mapper.mst.CustomerMapper;
+import com.dk.mdm.mapper.mst.StaffMapper;
 import com.dk.mdm.model.pojo.mst.CusFollow;
 import com.dk.mdm.mapper.mst.CusFollowMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.pojo.mst.CusFollowStaff;
+import com.dk.mdm.model.pojo.mst.Customer;
+import com.dk.mdm.model.query.mst.CusFollowQuery;
+import com.dk.mdm.model.query.mst.CustomerQuery;
+import com.dk.mdm.model.response.mst.CusFollowResponse;
+import com.dk.mdm.model.response.mst.CustomerResponse;
+import com.dk.common.model.response.mst.StaffResponse;
+import com.dk.mdm.model.vo.mst.CusFollowVO;
+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.time.LocalDateTime;
+import java.util.*;
+
 @Service
 @Transactional
 public class CusFollowService extends BaseService<CusFollow> {
 
-	@Override
-	public BaseMapper<CusFollow> getRepository() {
-		return cusFollowMapper;
-	}
+    @Override
+    public BaseMapper<CusFollow> getRepository() {
+        return cusFollowMapper;
+    }
+
+    @Autowired
+    private CusFollowMapper cusFollowMapper;
+
+    @Autowired
+    private CustomerMapper customerMapper;
+
+    @Autowired
+    private CustomerService customerService;
+
+    @Autowired
+    private CusFollowStaffMapper cusFollowStaffMapper;
+
+    @Autowired
+    private CommonService commonService;
+
+    @Autowired
+    private CusFollowConvert cusFollowConvert;
+
+    @Autowired
+    private StaffMapper staffMapper;
+
+
+    @Autowired
+    private AuthUtils authUtils;
+
+    /**
+     * @desc : 重写主键
+     * @author : 于继渤
+     * @date : 2024/2/29 20:29
+     */
+    @Override
+    public String getPrimaryKey() {
+        return "follow_id";
+    }
+
+
+    /**
+     * @desc : 查询
+     * @author : 于继渤
+     * @date : 2023/1/5 9:39
+     */
+    @Pagination
+    public ResponseResultVO<PageList<CusFollowResponse>> selectByCond(CusFollowQuery cusFollowQuery) {
+        return super.mergeListWithCount(cusFollowQuery, cusFollowMapper.selectByCond(cusFollowQuery),
+                cusFollowMapper.countByCond(cusFollowQuery));
+    }
+
+    public ResponseResultVO<List<CusFollowResponse>> selectByList(CusFollowQuery cusFollowQuery) {
+       return ResponseResultUtil.success(cusFollowMapper.selectByList(cusFollowQuery)) ;
+    }
+
+    /**
+     * @desc : 新建
+     * @author : 于继渤
+     * @date : 2023/1/5 9:39
+     */
+    @Transactional(
+            rollbackFor = {Exception.class}
+    )
+    public ResponseResultVO<?> insert(CusFollowVO cusFollowVO) {
+
+        if (cusFollowVO.getCusId() != null) {
+            //查询客户
+            Customer customer = customerMapper.selectById(cusFollowVO.getCusId());
+
+            // 查询跟进人是否存在
+            CusFollowStaff followStaff = cusFollowStaffMapper.selectByCusFollowStaffId(cusFollowVO.getCusId(), authUtils.getStaff().getStaffId());
+            //追加跟进人表
+            if (followStaff == null) {
+                cusFollowStaffMapper.insert(new CusFollowStaff()
+                        .setCusId(cusFollowVO.getCusId())
+                        .setFollowStaff(authUtils.getStaff().getStaffId())
+                        .setLastFollowId(authUtils.getStaff().getStaffId())
+                        .setLastFollowTime(LocalDateTime.now())
+                        .setCpId(authUtils.getStaff().getCpId())
+                        .setLastFollowStatus(cusFollowVO.getFollowStatus())
+                        .setFollowCount(1)
+                );
+            }
+            //追加跟进人
+            List<Long> users = new ArrayList<>();
+            Object o = customerMapper.selectFollowStaffs(cusFollowVO.getCusId());
+            if (o != null && o instanceof Long[]) {
+                users = Arrays.asList((Long[]) o);
+            }
+
+            if (users == null || users.size() == 0 || (users != null && users.stream().allMatch(Objects::isNull))) {
+                users = new ArrayList<>();
+            }
+
+
+            //公海客户跟进后 变成潜客状态
+            if (Constant.saleCustomerStatusConstant.SALE_STATUS_INTE.getName().equals(customer.getSaleStatus())) {
+                customer.setSaleStatus(Constant.saleCustomerStatusConstant.SALE_STATUS_POTE.getName());
+            }
+            //已流失客户重新接待后应该变成潜客
+            if (Constant.saleCustomerStatusConstant.SALE_STATUS_LOST.getName().equals(customer.getSaleStatus())) {
+                customer.setSaleStatus(Constant.saleCustomerStatusConstant.SALE_STATUS_POTE.getName());
+            }
+
+            //放入公海客户,清除跟进人
+            if (Constant.IntentionConstant.SEA.getValue().equals(cusFollowVO.getIntention())) {
+                customer.setFollowStaffs(new ArrayList<>());
+                customer.setSaleStatus(Constant.saleCustomerStatusConstant.SALE_STATUS_INTE.getName());
+            } else {
+                if (!users.contains(authUtils.getStaff().getStaffId())) {
+                    List arrList = new ArrayList(users);
+                    arrList.add(authUtils.getStaff().getStaffId());
+                    customer.setFollowStaffs(arrList);
+                }
+            }
+            //已流失客户,修改状态为流失
+            if (Constant.IntentionConstant.LOST.getValue().equals(cusFollowVO.getIntention())) {
+                customer.setSaleStatus(Constant.saleCustomerStatusConstant.SALE_STATUS_LOST.getName());
+            }
+
+            //如果不是留资接待 修改客户信息
+            if (!Constant.BasicDataConstant.FOLLOW_STATUS_4.getValue().equals(cusFollowVO.getFollowStatus())) {
+                customer.setCusName(cusFollowVO.getCusName());
+                customer.setCusPhone(cusFollowVO.getCusPhone());
+                customer.setAddressName(cusFollowVO.getAddressName());
+                customer.setAddressNo(cusFollowVO.getAddressNo());
+                customer.setAddressGcj02(cusFollowVO.getAddressGcj02());
+                customer.setAddressFull(cusFollowVO.getAddressFull());
+                customer.setAddressArea(cusFollowVO.getAddressArea());
+            }
+            customer.setCpId(authUtils.getStaff().getCpId());
+            // 同商户 电话不同
+            List<CustomerResponse> cusList = customerMapper.selectByCond(
+                    new CustomerQuery().setCpId(customer.getCpId()).setCusPhone(customer.getCusPhone()).setFlgValid(true)
+            );
+            if (cusList != null && cusList.size() > 0 && cusList.stream().anyMatch(a -> !a.getCusId().equals(customer.getCusId()))) {
+                throw new BaseBusinessException(ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getCode(),
+                        ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getMessage());
+            }
+            customerService.updateByUuid(customer);
+        } else if (cusFollowVO.getCusPhone() != null && cusFollowVO.getCusName() != null) {
+            //留资接待 新建客户
+            Customer customer = new Customer();
+            customer.setCusName(cusFollowVO.getCusName());
+            customer.setCusPhone(cusFollowVO.getCusPhone());
+            customer.setAddressName(cusFollowVO.getAddressName());
+            customer.setAddressNo(cusFollowVO.getAddressNo());
+            customer.setAddressGcj02(cusFollowVO.getAddressGcj02());
+            customer.setAddressFull(cusFollowVO.getAddressFull());
+            customer.setAddressArea(cusFollowVO.getAddressArea());
+            customer.setReportStaff(authUtils.getStaff().getStaffId());
+            customer.setReportTime(LocalDateTime.now());
+            customer.setCpId(authUtils.getStaff().getCpId());
+            customer.setOrgId(authUtils.getStaff().getOrgId());
+//            customer.setCustomerFrom(-1L);
+
+            // 同商户 电话不同
+            Long count = customerMapper.countByCond(
+                    new CustomerQuery().setCpId(customer.getCpId()).setCusPhone(customer.getCusPhone()).setFlgValid(true)
+            );
+            if (count > 0) {
+                return ResponseResultUtil.error(ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getCode(),
+                        ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getMessage());
+            }
+
+            //放入公海客户,清除跟进人
+            if (Constant.IntentionConstant.SEA.getValue().equals(cusFollowVO.getIntention())) {
+                customer.setFollowStaffs(new ArrayList<>());
+                customer.setSaleStatus(Constant.saleCustomerStatusConstant.SALE_STATUS_INTE.getName());
+            } else {
+                //当前跟进人(业务员)
+                customer.setFollowStaffs(new ArrayList<String>() {{
+                    add(authUtils.getStaff().getStaffId());
+                }});
+                customer.setSaleStatus(Constant.saleCustomerStatusConstant.SALE_STATUS_POTE.getName());
+            }
+
+            customer.setFollowCount(0);
+            //新建客户或编辑客户
+            customerMapper.insert(customer);
+
+            cusFollowVO.setCusId(customer.getCusId());
+        }
+
+
+        CusFollow cusFollow = cusFollowConvert.convertToPo(cusFollowVO);
+        //设置ID
+        Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSTOMERFOLLOW.getName(), true);
+        cusFollow.setFollowId(uniqueNoteCode.get("outId").toString());
+        //跟进时间
+        cusFollow.setFollowTime(LocalDateTime.now());
+        //跟进人
+        cusFollow.setFollowStaff(authUtils.getStaff().getStaffId());
+        //跟进部门
+        cusFollow.setFollowOrg(authUtils.getStaff().getOrgId());
+
+        // 约量尺
+        if (Constant.BasicDataConstant.FOLLOW_STATUS_3.getValue().equals(cusFollow.getFollowStatus())) {
+            // 量尺状态:待量尺
+            cusFollow.setMeasureStatus(Constant.BasicDataConstant.MEASURE_STATUS_2.getValue());
+        }
+        if (cusFollow.getFollowData() == null) {
+            cusFollow.setFollowData("无");
+        }
+        super.insert(cusFollow);
+
+
+        //设计师
+        StaffResponse designStaff = null;
+        if (cusFollow.getDesignStaff() != null) {
+
+            designStaff = staffMapper.selectById(cusFollow.getDesignStaff());
+
+        }
+
+        // 约尺 同意邀约 有设计师 设计师绑定企微
+        boolean pushFlag = Constant.BasicDataConstant.FOLLOW_STATUS_3.getValue().equals(cusFollow.getFollowStatus()) &&
+                Constant.BasicDataConstant.FOLLOW_INVITE_RESULT.getValue().equals(cusFollow.getInviteResult()) &&
+                designStaff != null;
+
+        if (cusFollow.getNextFollowTime() != null || pushFlag) {
+            // 保存跟进信息
+            //  saveToXxlJob(cusFollow);
+        }
+
+        return ResponseResultUtil.success();
+    }
+
 
-	@Autowired
-	private CusFollowMapper cusFollowMapper;
+/**
+ * @desc : 保存跟进信息到xxl job
+ * @author : 于继渤海
+ * @date : 2022-05-27 09:53
+ */
+//    @Transactional(rollbackFor = {Exception.class})
+//    public void saveToXxlJob(CusFollow cusFollow) {
+//
+//        Long nextId = followPlanMapper.getNextId();
+//
+//
+//        // 约量尺 && 接受邀约
+////        预约量尺,邀约结果接受,通知设计师提醒时间是(服务时间);邀约结果拒绝,通知创建者提醒时间是(提醒时间)
+//        if (Constant.BasicDataConstant.FOLLOW_STATUS_3.getValue().equals(follow.getFollowStatus()) &&
+//                Constant.BasicDataConstant.FOLLOW_INVITE_RESULT.getValue().equals(follow.getInviteResult())) {
+//            follow.setNextFollowTime(follow.getInviteTime()).setFollowUser(follow.getDesignUser());
+//        }
+//
+//        int id = xxlJobUtils.create(Math.toIntExact(
+//                (follow.getNextFollowTime().toInstant(ZoneOffset.of("+8")).toEpochMilli() - System.currentTimeMillis()) / 1000
+//        ), nextId, Constant.XxlJobInfo.FOLLOW.getValue());
+//
+//
+//        // 生成主键
+//        followPlanMapper.insert(
+//                new FollowPlan().setPlanId(nextId).setCustomerId(follow.getCustomerId())
+//                        .setPlanType(Constant.IntegerConstant.PLAN_TYPE_FOLLOW.getValue())
+//                        .setFollowId(follow.getFollowId())
+//                        .setFollowUser(follow.getFollowUser())
+//                        .setNextFollowPlan(follow.getNextFollowPlan())
+//                        .setNextFollowTime(follow.getNextFollowTime())
+//                        .setXxlJobId(id)
+//                        .setCpId(follow.getCpId())
+//        );
+//    }
 
 }

+ 44 - 7
src/main/java/com/dk/mdm/service/mst/CustomerService.java

@@ -2,8 +2,9 @@ package com.dk.mdm.service.mst;
 
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
-import com.dk.common.infrastructure.util.LocalDateTimeUtils;
+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.mst.CustomerConvert;
@@ -19,9 +20,11 @@ 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 org.springframework.web.bind.annotation.PathVariable;
 
 import java.time.LocalDateTime;
-import java.util.Date;
+import java.util.ArrayList;
+import java.util.List;
 import java.util.Map;
 
 @Service
@@ -43,6 +46,9 @@ public class CustomerService extends BaseService<Customer> {
     @Autowired
     private CommonService commonService;
 
+    @Autowired
+    private OrgService orgService;
+
 
     @Autowired
     private AuthUtils authUtils;
@@ -83,16 +89,37 @@ public class CustomerService extends BaseService<Customer> {
         Map<String, Object> uniqueNoteCode = commonService.getUniqueNoteCode(Constant.docNameConstant.CUSTOMER.getName(), true);
         customer.setCusId(uniqueNoteCode.get("outId").toString());
         customer.setCusCode(uniqueNoteCode.get("outNote").toString());
+
+        // 同商户 电话不同
+        Long count = customerMapper.countByCond(
+                new CustomerQuery().setCpId(customer.getCpId()).setCusPhone(customer.getCusPhone()).setFlgValid(true)
+        );
+        if (count > 0) {
+            return ResponseResultUtil.error(ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getCode(),
+                    ErrorCodeEnum.CUSTOMER_SAME_COMPANY_TELEPHONE.getMessage());
+        }
+        List<String> followStaff = new ArrayList<>();
+        followStaff.add(authUtils.getStaff().getStaffId());
+        customer.setFollowStaffs(followStaff);
+        if (customer.getSaleStatus() == null) {
+            //新建默认就是潜客
+            customer.setSaleStatus(Constant.saleCustomerStatusConstant.SALE_STATUS_POTE.getName());
+        }
+
+
         //设置公司id
         customer.setCpId(authUtils.getStaff().getCpId());
-        //设置报备人
+        //报备人
         customer.setReportStaff(authUtils.getStaff().getStaffId());
         //报备日期
         customer.setReportTime(LocalDateTime.now());
-        //销售状态 (【系统字典】客销状态:公海、潜客、成
-        customer.setSaleStatus(Constant.SaleStatus.QIANKE.getName());
-        customerMapper.insert(customer);
-        return ResponseResultUtil.success();
+        ResponseResultVO<?> insert = super.insert(customer);
+        if (insert.getCode() == ResponseCodeEnum.SUCCESS.getCode()) {
+            return ResponseResultUtil.success(customer);
+        } else {
+            return insert;
+        }
+
     }
 
     /**
@@ -108,4 +135,14 @@ public class CustomerService extends BaseService<Customer> {
         super.updateByUuid(customer);
         return ResponseResultUtil.success();
     }
+
+
+    public ResponseResultVO<CustomerResponse> selectByIdRespone(@PathVariable String id) {
+        CustomerResponse customerResponse = customerMapper.selectByIdRespone(id);
+        if (customerResponse == null) {
+            return ResponseResultUtil.error(ResponseCodeEnum.SELECT_NULL);
+        }
+        return ResponseResultUtil.success(customerResponse);
+    }
+
 }

+ 4 - 1
src/main/java/com/dk/mdm/service/mst/GoodsBrandService.java

@@ -81,7 +81,10 @@ public class GoodsBrandService extends BaseService<GoodsBrand> {
     public ResponseResultVO<?> insert(GoodsBrandVO goodsBrandVO) {
         //实体转换
         GoodsBrand goodsBrand = goodsBrandConvert.convertToPo(goodsBrandVO);
-        goodsBrand.setShortName(goodsBrand.getBrandName());
+        // 品牌简称
+        if(goodsBrand.getShortName() == null){
+            goodsBrand.setShortName(goodsBrand.getBrandName());
+        }
         //设置序号
         goodsBrand.setDisplayNo(commonService.getMaxDisplayNo(Constant.DisplayNoTable.GOODSBRAND));
         //设置编码

+ 12 - 6
src/main/java/com/dk/mdm/service/mst/StaffService.java

@@ -1,13 +1,12 @@
 package com.dk.mdm.service.mst;
 
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.model.pojo.PageList;
-import com.dk.common.model.vo.core.StaffEntity;
 import com.dk.common.response.ResponseCodeEnum;
 import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
+import com.dk.mdm.feign.CompanyFeign;
 import com.dk.mdm.infrastructure.convert.mst.StaffConvert;
 import com.dk.mdm.infrastructure.util.AuthUtils;
 import com.dk.mdm.model.pojo.mst.*;
@@ -15,7 +14,7 @@ import com.dk.mdm.mapper.mst.StaffMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.query.mst.StaffQuery;
-import com.dk.mdm.model.response.mst.StaffResponse;
+import com.dk.common.model.response.mst.StaffResponse;
 import com.dk.mdm.model.vo.mst.StaffVO;
 import com.dk.mdm.service.common.CommonService;
 import org.springframework.stereotype.Service;
@@ -23,10 +22,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
 
+import javax.annotation.Resource;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Random;
-import java.util.UUID;
 
 /**
  * @author : 姜永辉
@@ -35,6 +34,9 @@ import java.util.UUID;
  */
 @Service
 public class StaffService extends BaseService<Staff> {
+    @Resource
+    private CompanyFeign companyFeign;
+
 
     @Override
     public BaseMapper<Staff> getRepository() {
@@ -129,7 +131,11 @@ public class StaffService extends BaseService<Staff> {
         staff.setStaffCode(codeMap.get("outNote").toString());
         // 更新 被邀人员的cpid
         if (staff.getWxUserId()!=null){
-
+            // 更新邀请人员的微信用户的cpid 加入公司
+            Map<String, Object> collectQuery = new HashMap<>();
+            collectQuery.put("cpId", staff.getCpId());
+            collectQuery.put("userId", staff.getWxUserId());
+            companyFeign.updateWxUserCompany(collectQuery);
         }
         // 插入员工
         return super.insert(staff);