Просмотр исходного кода

Merge remote-tracking branch 'origin/master'

dongke 1 год назад
Родитель
Сommit
0cff0daddc
29 измененных файлов с 718 добавлено и 131 удалено
  1. 11 0
      src/main/java/com/dk/mdm/controller/ivt/inventory/InventoryController.java
  2. 40 0
      src/main/java/com/dk/mdm/controller/report/ReportController.java
  3. 7 0
      src/main/java/com/dk/mdm/feign/CompanyFeign.java
  4. 2 0
      src/main/java/com/dk/mdm/mapper/common/CommonMapper.java
  5. 6 1
      src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml
  6. 2 2
      src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml
  7. 13 0
      src/main/java/com/dk/mdm/mapper/ivt/InventoryMapper.java
  8. 164 1
      src/main/java/com/dk/mdm/mapper/ivt/InventoryMapper.xml
  9. 7 1
      src/main/java/com/dk/mdm/mapper/mst/ComMenuMapper.java
  10. 6 0
      src/main/java/com/dk/mdm/mapper/mst/ComMenuMapper.xml
  11. 1 0
      src/main/java/com/dk/mdm/mapper/mst/StaffMapper.java
  12. 35 0
      src/main/java/com/dk/mdm/mapper/report/ReportMapper.java
  13. 177 3
      src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml
  14. 2 9
      src/main/java/com/dk/mdm/mapper/sale/OrderItemMapper.xml
  15. 7 0
      src/main/java/com/dk/mdm/mapper/sale/OrderMapper.java
  16. 10 0
      src/main/java/com/dk/mdm/mapper/sale/OrderMapper.xml
  17. 6 10
      src/main/java/com/dk/mdm/model/pojo/mst/GoodsSku.java
  18. 3 3
      src/main/java/com/dk/mdm/model/pojo/sale/Order.java
  19. 6 12
      src/main/java/com/dk/mdm/model/pojo/sale/OrderItem.java
  20. 6 13
      src/main/java/com/dk/mdm/model/response/sale/OrderItemResponse.java
  21. 3 3
      src/main/java/com/dk/mdm/model/response/sale/OrderResponse.java
  22. 4 11
      src/main/java/com/dk/mdm/model/vo/sale/OrderItemVO.java
  23. 1 1
      src/main/java/com/dk/mdm/model/vo/sale/OrderVO.java
  24. 1 0
      src/main/java/com/dk/mdm/service/common/CommonService.java
  25. 24 28
      src/main/java/com/dk/mdm/service/ivt/inventory/InventoryService.java
  26. 29 10
      src/main/java/com/dk/mdm/service/mst/GoodsSkuService.java
  27. 81 22
      src/main/java/com/dk/mdm/service/mst/StaffService.java
  28. 63 0
      src/main/java/com/dk/mdm/service/report/ReportService.java
  29. 1 1
      src/main/java/com/dk/mdm/service/sale/OrderService.java

+ 11 - 0
src/main/java/com/dk/mdm/controller/ivt/inventory/InventoryController.java

@@ -41,4 +41,15 @@ public class InventoryController{
         return inventoryService.selectByCond(query);
     }
 
+    /**
+     * @desc   : 库存预警条件查询
+     * @date   : 2024/6/13 15:33
+     * @author : 刘尧
+     */
+    @ApiOperation(value = "库存预警条件查询", notes = "库存预警条件查询")
+    @PostMapping({"warning_list_by"})
+    public ResponseResultVO<PageList<InventoryResponse>> warningSelectByCond(@RequestBody InventoryQuery query) {
+        return inventoryService.warningSelectByCond(query);
+    }
+
 }

+ 40 - 0
src/main/java/com/dk/mdm/controller/report/ReportController.java

@@ -318,6 +318,46 @@ public class ReportController  {
         return reportService.getCusRecPayReportItem(params);
     }
 
+
+    /**
+     * @desc   : 查询销售利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    @PostMapping("get_sale_profit")
+    public ResponseResultVO<Map<String, Object>> getSaleProfit(@RequestBody Map<String, Object> param) {
+        return reportService.getSaleProfit(param);
+    }
+
+    /**
+     * @desc   : 查询部门利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    @PostMapping("get_sale_profit_group_by_org")
+    public ResponseResultVO<Map<String, Object>> getSaleProfitGroupByOrg(@RequestBody Map<String, Object> param) {
+        return reportService.getSaleProfitGroupByOrg(param);
+    }
+
+    /**
+     * @desc   : 查询业务员利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    @PostMapping("get_sale_profit_group_by_staff")
+    public ResponseResultVO<Map<String, Object>> getSaleProfitGroupByStaff(@RequestBody Map<String, Object> param) {
+        return reportService.getSaleProfitGroupByStaff(param);
+    }
+
+    /**
+     * @desc   : 查询商品利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    @PostMapping("get_sale_profit_group_by_sku")
+    public ResponseResultVO<Map<String, Object>> getSaleProfitGroupBySku(@RequestBody Map<String, Object> param) {
+        return reportService.getSaleProfitGroupBySku(param);
+    }
 }
 
 

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

@@ -42,4 +42,11 @@ public interface CompanyFeign {
     @PostMapping({"/get_company_max_staff_num/{id}"})
     ResponseResultVO<?> getCompanyMaxStaffNum(@PathVariable Integer id) ;
 
+    /**
+     * @desc   : 可以绑定微信的员工人数  人数上限
+     * @author : 姜永辉
+     * @date   : 2023-11-02 16:27
+     */
+    @PostMapping({"/get_comMenu/{gradeCode}"})
+    ResponseResultVO<?> getComMenu(@PathVariable String gradeCode) ;
 }

+ 2 - 0
src/main/java/com/dk/mdm/mapper/common/CommonMapper.java

@@ -57,6 +57,8 @@ public interface CommonMapper extends BaseMapper<Map<String, Object>> {
      */
     List<Map<String, Object>> getDataKind(Map param);
 
+
+
     /**
      * @desc : 获取组织部门
      * @author : 姜宁

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

@@ -154,8 +154,12 @@
             AND kind_code =any(#{kindCodeList,typeHandler=StringListTypeHandler})
         </if>
         order by display_no
+        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
+            limit #{end} offset #{start}
+        </if>
     </select>
 
+
     <!-- 获取组织部门 -->
     <select id="getOrg" resultType="java.util.Map">
         select org_Id     AS "orgId",
@@ -1958,6 +1962,7 @@
                   AND s.hr_status = 1
                   AND s.login_type IN ( 2, 3 )
                   AND s.cp_id = #{cpId}
-            )
+            ),
+            CURRENT_DATE as "currentDate"
     </select>
 </mapper>

+ 2 - 2
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -589,8 +589,8 @@
         <include refid="Base_Column_List_Response"/>
         ,tpid.into_no as "intoNo"
         ,tmgs.sku_code  as "skuCode"
-        ,tmgs.sku_model as "skuModel"
-        ,tmgs.sku_name  as "skuName"
+        ,tpii.sku_model as "skuModel"
+        ,tpii.sku_name  as "skuName"
         ,tmgs.sku_spec  as "skuSpec"
         ,tmgb.brand_name  as "brandName"
         ,tmgb.short_name  as "shortName"

+ 13 - 0
src/main/java/com/dk/mdm/mapper/ivt/InventoryMapper.java

@@ -42,6 +42,13 @@ public interface InventoryMapper extends BaseMapper<Inventory>{
     Long countByCond(InventoryQuery inventoryQuery);
 
     /**
+     * @desc   : 库存预警条件查询个数
+     * @date   : 2024/6/13 17:04
+     * @author : 刘尧
+     */
+    Long warningCountByCond(InventoryQuery inventoryQuery);
+
+    /**
      * @desc   : 条件查询--查单条
      * @date   : 2024/3/20 17:00
      * @author : 寇珊珊
@@ -79,5 +86,11 @@ public interface InventoryMapper extends BaseMapper<Inventory>{
      */
     int updateCost(Inventory inventory);
 
+    /**
+     * @desc   : 库存预警条件查询
+     * @date   : 2024/6/13 17:04
+     * @author : 刘尧
+     */
+    List<InventoryResponse> warningSelectByCond(InventoryQuery inboundQuery);
 }
 

+ 164 - 1
src/main/java/com/dk/mdm/mapper/ivt/InventoryMapper.xml

@@ -139,7 +139,6 @@
             </if>
             <if test="invQtyFlag != null and invQtyFlag = true">
                 and tpi.inv_qty != 0
-
             </if>
         </where>
     </sql>
@@ -307,6 +306,170 @@
             </if>
         </where>
     </select>
+    <select id="warningCountByCond" resultType="java.lang.Long">
+        SELECT
+        count(1)
+        FROM dkic_b.t_psi_inventory tpi
+        <include refid="Join_Table"/>
+        <where>
+            (tmgs.warning_lower_limit &lt;&gt; 0 OR tmgs.warning_upper_limit &lt;&gt; 0)
+            AND (tpi.inv_qty > tmgs.warning_lower_limit OR tpi.inv_qty > tmgs.warning_upper_limit)
+            <if test="whId != null and whId != ''">
+                AND tpi.wh_id = #{whId}::UUID
+            </if>
+            <if test="whIds != null and whIds.size()>0">
+                AND tpi.wh_id =
+                any(#{whIds, typeHandler=UuidListTypeHandler})
+            </if>
+            <if test="skuId != null and skuId != ''">
+                AND tpi.sku_id = #{skuId}
+            </if>
+            <if test="nonStdCode != null and nonStdCode != ''">
+                AND tpi.non_std_code = #{nonStdCode}
+            </if>
+            <if test="invQty != null">
+                AND tpi.inv_qty = #{invQty}
+            </if>
+            <if test="outingQty != null">
+                AND tpi.outing_qty = #{outingQty}
+            </if>
+            <if test="usableQty != null">
+                AND tpi.usable_qty = #{usableQty}
+            </if>
+            <if test="costPrice != null">
+                AND tpi.cost_price = #{costPrice}
+            </if>
+            <if test="costAmt != null">
+                AND tpi.cost_amt = #{costAmt}
+            </if>
+            <if test="flgValid != null">
+                AND tpi.flg_valid = #{flgValid}
+            </if>
+            <if test="flgZero == true">
+                AND tpi.inv_qty != 0
+            </if>
+            <if test="cpId != null">
+                AND tpi.cp_id = #{cpId}
+            </if>
+            <if test="freezeQty != null">
+                AND tpi.freeze_qty = #{freezeQty}
+            </if>
+            <if test="categoryId != null and categoryId != ''">
+                AND tmgs.category_id = #{categoryId}::UUID
+            </if>
+            <if test="brandId != null and brandId != ''">
+                AND tmgs.brand_id = #{brandId}::UUID
+            </if>
+            <if test="searchText != null">
+                AND (tmgs.sku_model  like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR  tmgs.sku_name like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR  tpi.non_std_code like concat('%', my_ex.likequery(#{searchText}) , '%')
+                )
+            </if>
+            <if test="invQtyFlag != null and invQtyFlag = true">
+                and tpi.inv_qty != 0
+            </if>
+        </where>
+    </select>
+
+    <select id="warningSelectByCond" resultType="com.dk.mdm.model.response.ivt.InventoryResponse">
+        SELECT
+        <include refid="Base_Column_List_Response"/>
+        ,tmgs.sku_code
+        ,tmgs.sku_model
+        ,tmgs.sku_name
+        ,tmgs.sku_spec
+        ,tmgs.price_purchase
+        ,tmgs.price_standard
+        ,tmgs.price_wholesale
+        ,tmgs.price_other
+        ,tmgs.price_limited
+        ,tmgs.sku_images
+        ,tmgs.unit_id
+        ,tmgs.sub_unit_id
+        ,tmgs.warning_upper_limit
+        ,tmgs.warning_lower_limit
+        ,tmgs.pack_box
+        ,tmu.unit_name    AS "unitName"
+        ,subtmu.unit_name AS "subUnitName"
+        ,tmgs.flg_sub_unit
+        ,tmgb.brand_name
+        ,tmgb.short_name
+        ,tmw.wh_name
+        ,tmgc.cat_name as "catName"
+        ,tmgseries.series_name as "seriesName"
+        ,tmu.decimal_places    as "decimalPlaces"
+        FROM dkic_b.t_psi_inventory tpi
+        <include refid="Join_Table"/>
+        <where>
+            (tmgs.warning_lower_limit &lt;&gt; 0 OR tmgs.warning_upper_limit &lt;&gt; 0)
+            AND (tpi.inv_qty > tmgs.warning_lower_limit OR tpi.inv_qty > tmgs.warning_upper_limit)
+            <if test="whId != null and whId != ''">
+                AND tpi.wh_id = #{whId}::UUID
+            </if>
+            <if test="whIds != null and whIds.size()>0">
+                AND tpi.wh_id =
+                any(#{whIds, typeHandler=UuidListTypeHandler})
+            </if>
+            <if test="skuId != null and skuId != ''">
+                AND tpi.sku_id = #{skuId}
+            </if>
+            <if test="nonStdCode != null and nonStdCode != ''">
+                AND tpi.non_std_code = #{nonStdCode}
+            </if>
+            <if test="invQty != null">
+                AND tpi.inv_qty = #{invQty}
+            </if>
+            <if test="outingQty != null">
+                AND tpi.outing_qty = #{outingQty}
+            </if>
+            <if test="usableQty != null">
+                AND tpi.usable_qty = #{usableQty}
+            </if>
+            <if test="costPrice != null">
+                AND tpi.cost_price = #{costPrice}
+            </if>
+            <if test="costAmt != null">
+                AND tpi.cost_amt = #{costAmt}
+            </if>
+            <if test="flgValid != null">
+                AND tpi.flg_valid = #{flgValid}
+            </if>
+            <if test="flgZero == true">
+                AND tpi.inv_qty != 0
+            </if>
+            <if test="cpId != null">
+                AND tpi.cp_id = #{cpId}
+            </if>
+            <if test="freezeQty != null">
+                AND tpi.freeze_qty = #{freezeQty}
+            </if>
+            <if test="categoryId != null and categoryId != ''">
+                AND tmgs.category_id = #{categoryId}::UUID
+            </if>
+            <if test="brandId != null and brandId != ''">
+                AND tmgs.brand_id = #{brandId}::UUID
+            </if>
+            <if test="searchText != null">
+                AND (tmgs.sku_model  like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR  tmgs.sku_name like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR  tpi.non_std_code like concat('%', my_ex.likequery(#{searchText}) , '%')
+                )
+            </if>
+            <if test="invQtyFlag != null and invQtyFlag = true">
+                and tpi.inv_qty != 0
+            </if>
+        </where>
+        <if test="desc != null and desc != ''">
+            order by tpi.usable_qty desc
+        </if>
+        <if test="desc == null or desc == ''">
+            order by tpi.usable_qty
+        </if>
+        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
+            limit #{end} offset #{start}
+        </if>
+    </select>
 
     <!--修改库存数量金额-->
     <update id="updateAmountAndQuantity" parameterType="com.dk.mdm.model.vo.ivt.InventoryVO">

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

@@ -4,6 +4,7 @@ import com.dk.mdm.model.pojo.mst.ComMenu;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.pojo.mst.MenuFrequency;
 import com.dk.mdm.model.query.mst.ComMenuQuery;
+import com.dk.mdm.model.query.mst.StaffQuery;
 import com.dk.mdm.model.response.mst.ComMenuResponse;
 import com.dk.mdm.model.vo.mst.ComMenuVO;
 import org.apache.ibatis.annotations.Param;
@@ -44,6 +45,11 @@ public interface ComMenuMapper extends BaseMapper<ComMenu>{
      */
     int deleteMenuByStaff(@Param("staffId") String staffId);
 
-
+    /**
+     * @desc   : 删除该公司的常用功能
+     * @author : 周兴
+     * @date   : 2024-03-29 10:30
+     */
+    int deleteMenuByCpId(Integer cpId);
 }
 

+ 6 - 0
src/main/java/com/dk/mdm/mapper/mst/ComMenuMapper.xml

@@ -64,6 +64,7 @@
         WHERE
             tmcm.staff_id = #{staffId} ::uuid
           AND tmcm.app_code = #{appCode}
+          AND tmcm.cp_id = #{cpId}
         <if test="gradeCode != null and gradeCode != ''">
             AND (tam.grade_codes is null or #{gradeCode} = any(tam.grade_codes))
         </if>
@@ -108,6 +109,11 @@
         delete from dkic_b.t_mst_com_menu where staff_id = #{staffId} ::uuid
     </delete>
 
+    <!--删除常用功能-->
+    <delete id="deleteMenuByCpId">
+        delete from dkic_b.t_mst_com_menu where cp_id = #{cpId}
+    </delete>
+
     <!--新建编辑常用功能-->
     <insert id="save">
         insert into dkic_b.t_mst_com_menu

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

@@ -52,5 +52,6 @@ public interface StaffMapper extends BaseMapper<Staff>{
      */
     StaffResponse selectById(@Param("id") String id);
 
+
 }
 

+ 35 - 0
src/main/java/com/dk/mdm/mapper/report/ReportMapper.java

@@ -272,4 +272,39 @@ public interface ReportMapper extends BaseMapper<JSONObject> {
      * @date   : 2024/6/5 17:28
      * */
     List<Map<String, Object>> getUserArrears(Map params);
+
+    /**
+     * @desc   : 查询销售利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    Map<String, Object> getSaleProfit(Map params);
+
+    /**
+     * @desc   : 查询销售利润 按日或按月
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    List<Map<String, Object>> getSaleProfitGroupByDate(Map params);
+
+    /**
+     * @desc   : 查询部门利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    List<Map<String, Object>> getSaleProfitGroupByOrg(Map params);
+
+    /**
+     * @desc   : 查询业务员利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    List<Map<String, Object>> getSaleProfitGroupByStaff(Map params);
+
+    /**
+     * @desc   : 查询商品利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    List<Map<String, Object>> getSaleProfitGroupBySku(Map params);
 }

+ 177 - 3
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -1540,7 +1540,10 @@
              tmc.cus_id AS "cusId",
              tmc.cus_code AS "cusCode",
              tmc.cus_name AS "cusName",
-             tmc.cus_phone AS "cusPhone"
+             tmc.cus_phone AS "cusPhone",
+        tmgs.sku_spec as "skuSpec",
+        concat ( sys.f_remove_zero ( T.item_qty ), tmgu.unit_name ) AS "itemQtyPiece",
+        dkic_b.f_box_piece ( tmgus.unit_name, tmgu.unit_name, T.BOX, T.piece ) AS "boxPiece"
         FROM dkic_b.t_psi_order_item as t
         inner join dkic_b.t_psi_order tpo on tpo.order_id = t.order_id
         inner join dkic_b.t_mst_goods_sku tmgs on t.sku_id = tmgs.sku_id
@@ -1548,8 +1551,10 @@
         left join dkic_b.t_mst_customer tmc on tmc.cus_id = tpo.cus_id
         LEFT JOIN dkic_b.t_mst_goods_brand tmgb ON tmgb.brand_id = tmgs.brand_id
         left join sys.t_data_kind as tdk3 on tpo.out_status = tdk3.kind_code
+        LEFT JOIN dkic_b.t_mst_unit AS tmgu ON tmgs.unit_id = tmgu.unit_id
+        LEFT JOIN dkic_b.t_mst_unit AS tmgus ON tmgs.sub_unit_id = tmgus.unit_id
         <include refid="ConditionSaleItem"/>
-        order by t.item_index
+        order by tpo.make_time,t.item_index
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}
         </if>
@@ -1617,12 +1622,45 @@
             <if test="cpId != null">
                 AND t.cp_id = #{cpId}
             </if>
+            <if test="makeTimeStart != null and makeTimeEnd != null">
+                AND tpo.make_time &gt;= #{makeTimeStart}::timestamp with time zone
+                AND tpo.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
+            </if>
+            <if test="skuName != null and skuName != ''">
+                AND tmgs.sku_name like concat('%', my_ex.likequery(#{skuName}) , '%')
+            </if>
+            <if test="skuModel != null and skuModel != ''">
+                AND tmgs.sku_model like concat('%', my_ex.likequery(#{skuModel}) , '%')
+            </if>
+            <if test="brandName != null and brandName != ''">
+                AND tmgb.brand_name like concat('%', my_ex.likequery(#{brandName}) , '%')
+            </if>
+            <if test="whName != null and whName != ''">
+                AND tmw.wh_name like concat('%', my_ex.likequery(#{whName}) , '%')
+            </if>
+            <if test="nonStdCode != null and nonStdCode != ''">
+                AND t.non_std_code like concat('%', my_ex.likequery(#{nonStdCode}) , '%')
+            </if>
+            <if test="searchText !=null and searchText != ''">
+                AND (
+                tpo.order_no   LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tmc.cus_phone LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                or tmc.cus_name LIKE concat('%',my_ex.likequery(#{searchText}),'%')
+                )
+            </if>
+            <if test="isFlgGift != null and isFlgGift == true">
+                AND t.flg_gift
+            </if>
+            <if test="isExtCo != null and isExtCo == true">
+                AND t.sku_id  is null
+            </if>
         </where>
     </sql>
     <select id="getSalesItemReportCount" resultType="java.lang.Long">
         SELECT count(1)
         FROM
          dkic_b.t_psi_order_item t
+        inner join dkic_b.t_psi_order tpo on tpo.order_id = t.order_id
         <include refid="ConditionSaleItem"/>
     </select>
 
@@ -3014,8 +3052,144 @@
             OR tmc.address_full LIKE concat('%',#{searchText},'%'))
         </if>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
-            LIMIT #{pageSize} OFFSET #{currentPage}
+            limit #{end} offset #{start}
+        </if>
+    </select>
+
+    <!--region 销售利润-->
+
+    <select id="getSaleProfit" resultType="java.util.Map">
+        select
+        t.outbound, t.inbound,
+        t.outbound - t.inbound "profit",
+        <include refid="getSaleProfitRate"/>
+        from (
+        select
+        <include refid="getSaleProfitInOutBound"/>
+        from dkic_b.t_psi_in_out_record tpr
+        where tpr.cp_id = #{cpId}
+        <if test="makeTimeStart != null and makeTimeEnd != null">
+            AND tpr.op_create_time &gt;= #{makeTimeStart}::timestamp with time zone
+            AND tpr.op_create_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
+        </if>
+        ) t
+    </select>
+
+    <select id="getSaleProfitGroupByDate" resultType="java.util.Map">
+        select acc_date "accDate",
+        t.outbound - t.inbound "profit",
+        <include refid="getSaleProfitRate"/>
+        from (select
+        <if test="byDate==null or (byDate!=null and byDate=='false')">
+            to_char(acc_date, 'yyyy-mm') acc_date,
+        </if>
+        <if test="byDate!=null and byDate=='true'">
+            to_char(acc_date, 'mm-dd') acc_date,
+        </if>
+        <include refid="getSaleProfitInOutBound"/>
+        from dkic_b.t_psi_in_out_record tpr
+        <include refid="getSaleProfitCond"/>
+        group by
+        <if test="byDate==null or (byDate!=null and byDate=='false')">
+            to_char(acc_date, 'yyyy-mm')
+        </if>
+        <if test="byDate!=null and byDate=='true'">
+            to_char(acc_date, 'mm-dd')
         </if>
+        ) t
+        order by t.acc_date
+    </select>
+
+    <select id="getSaleProfitGroupByOrg" resultType="java.util.Map">
+        select tmo.org_name "orgName", tt.profit, tt."profitRate"
+        from (
+        select t.org_id,
+        t.outbound - t.inbound "profit",
+        <include refid="getSaleProfitRate"/>
+        from (select coalesce(tpi.org_id, tpo.org_id) org_id,
+        <include refid="getSaleProfitInOutBound"/>
+        from dkic_b.t_psi_in_out_record tpr
+        left join dkic_b.t_psi_inbound tpi on tpi.into_id = biznis_id
+        left join dkic_b.t_psi_outbound tpo on tpo.out_id = biznis_id
+        <include refid="getSaleProfitCond"/>
+        group by coalesce(tpi.org_id, tpo.org_id)) t
+        ) tt
+        left join dkic_b.t_mst_org tmo on tmo.org_id = tt.org_id
+        <include refid="getSaleProfitLimit"/>
+    </select>
+
+    <select id="getSaleProfitGroupByStaff" resultType="java.util.Map">
+        select tms.staff_name "staffName", tt.profit, tt."profitRate"
+        from (
+        select t.staff_id,
+        t.outbound - t.inbound "profit",
+        <include refid="getSaleProfitRate"/>
+        from (select coalesce(tpi.staff_id, tpo.staff_id) staff_id,
+        <include refid="getSaleProfitInOutBound"/>
+        from dkic_b.t_psi_in_out_record tpr
+        left join dkic_b.t_psi_inbound tpi on tpi.into_id = biznis_id
+        left join dkic_b.t_psi_outbound tpo on tpo.out_id = biznis_id
+        <include refid="getSaleProfitCond"/>
+        group by coalesce(tpi.staff_id, tpo.staff_id)) t
+        ) tt
+        left join dkic_b.t_mst_staff tms on tms.staff_id = tt.staff_id
+        <include refid="getSaleProfitLimit"/>
+    </select>
+
+    <select id="getSaleProfitGroupBySku" resultType="java.util.Map">
+        select tmgs.sku_name "skuName", tt.profit, tt."profitRate"
+        from (
+        select t.sku_id,
+        t.outbound - t.inbound "profit",
+        <include refid="getSaleProfitRate"/>
+        from (select sku_id sku_id,
+        <include refid="getSaleProfitInOutBound"/>
+        from dkic_b.t_psi_in_out_record tpr
+        <include refid="getSaleProfitCond"/>
+        group by sku_id) t
+        ) tt
+        left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id = tt.sku_id
+        <include refid="getSaleProfitLimit"/>
     </select>
 
+    <sql id="getSaleProfitInOutBound">
+        SUM(case biznis_type when 't_psi_outbound' then abs(tpr.into_amt) else 0 end) outbound,
+        SUM(case biznis_type when 't_psi_inbound' then abs(tpr.into_amt) else 0 end) inbound
+    </sql>
+
+    <sql id="getSaleProfitCond">
+        where tpr.cp_id = #{cpId}
+        <if test="makeTimeStart != null and makeTimeEnd != null">
+            AND tpr.op_create_time &gt;= #{makeTimeStart}::timestamp with time zone
+            AND tpr.op_create_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
+        </if>
+    </sql>
+
+    <sql id="getSaleProfitLimit">
+        <if test="orderBy != null and orderBy=='profitAsc'">
+            order by tt.profit
+        </if>
+        <if test="orderBy == null or orderBy=='profitDesc'">
+            order by tt.profit desc
+        </if>
+        <if test="orderBy != null and orderBy=='rateAsc'">
+            order by tt.profitRate
+        </if>
+        <if test="orderBy != null and orderBy=='rateDsc'">
+            order by tt.profitRate desc
+        </if>
+        <if test="limit!=null and limit">
+            limit 5
+        </if>
+    </sql>
+
+    <sql id="getSaleProfitRate">
+        case
+        when t.inbound = 0 then 0
+        else
+        round((t.outbound - t.inbound) / t.inbound * 100, 2)
+        end "profitRate"
+    </sql>
+
+    <!--endregion-->
 </mapper>

+ 2 - 9
src/main/java/com/dk/mdm/mapper/sale/OrderItemMapper.xml

@@ -10,7 +10,7 @@
         sys.f_remove_zero(item_qty) as item_qty, price_std, amt_std, price_sale, item_amt, price_discount, non_std_code, out_status,
         sys.f_remove_zero(outing_qty) as outing_qty, outing_amt, sys.f_remove_zero(out_qty) as out_qty, out_amt,
         sys.f_remove_zero(return_qty) as return_qty, return_amt, remarks, flg_valid, cp_id, wh_id,
-        fact_price,fact_amt,disc_amt,use_place,discount
+        fact_price,fact_amt,use_place,discount
     </sql>
 
     <sql id="Base_Column_List_Response">
@@ -18,7 +18,7 @@
         t.out_status, sys.f_remove_zero(t.outing_qty) as outing_qty, t.outing_amt, sys.f_remove_zero(t.out_qty) as out_qty, t.out_amt,
         sys.f_remove_zero(t.return_qty) as return_qty, t.return_amt, t.remarks, t.flg_valid, t.cp_id, t.wh_id
         ,t.box,t.piece,t.sub_unit_id,t.unit_id,t.pack_box,
-        t.fact_price,t.fact_amt,t.disc_amt,t,use_place,t.discount
+        t.fact_price,t.fact_amt,t,use_place,t.discount
     </sql>
 
     <!-- 通用查询映射结果 -->
@@ -53,7 +53,6 @@
         <result column="decimalPlaces" property="decimalPlaces"/>
         <result column="fact_price" property="factPrice"/>
         <result column="fact_amt" property="factAmt"/>
-        <result column="disc_amt" property="discAmt"/>
         <result column="use_place" property="usePlace"/>
         <result column="discount" property="discount"/>
     </resultMap>
@@ -95,7 +94,6 @@
         <result column="decimalPlaces" property="decimalPlaces"/>
         <result column="fact_price" property="factPrice"/>
         <result column="fact_amt" property="factAmt"/>
-        <result column="disc_amt" property="discAmt"/>
         <result column="use_place" property="usePlace"/>
         <result column="discount" property="discount"/>
     </resultMap>
@@ -198,7 +196,6 @@
                t.price_discount,
                t.fact_price,
                t.fact_amt,
-               t.disc_amt,
                t.use_place,
                t.discount,
                t.non_std_code,
@@ -519,9 +516,6 @@
             <if test=" et!=null and et.cpId != null">
                 fact_amt = #{et.factAmt,jdbcType=NUMERIC},
             </if>
-            <if test=" et!=null and et.cpId != null">
-                disc_amt = #{et.discAmt,jdbcType=NUMERIC},
-            </if>
             <if test=" et!=null and et.usePlace != null">
                 use_place = #{et.usePlace,jdbcType=VARCHAR},
             </if>
@@ -635,7 +629,6 @@
         t.price_discount,
         t.fact_price,
         t.fact_amt,
-        t.disc_amt,
         t.use_place,
         t.discount,
         t.non_std_code,

+ 7 - 0
src/main/java/com/dk/mdm/mapper/sale/OrderMapper.java

@@ -23,6 +23,13 @@ public interface OrderMapper extends BaseMapper<Order>{
     List<OrderResponse> selectByCond(OrderQuery orderQuery);
 
     /**
+     * @desc   : countByCond被改了,重写一个
+     * @author : 付斌
+     * @date   : 2024-02-28 10:19
+     */
+    Long countByCondForSelectByCond(OrderQuery orderQuery);
+
+    /**
      * @desc : 以销定采 查询
      * @author : 王英杰
      * @date : 2023/3/14 10:36

+ 10 - 0
src/main/java/com/dk/mdm/mapper/sale/OrderMapper.xml

@@ -553,6 +553,16 @@
             limit #{end} offset #{start}
         </if>
     </select>
+
+    <!-- countByCond被改了,重写一个 -->
+    <select id="countByCondForSelectByCond" resultType="Long">
+        SELECT
+        count(1)
+        FROM dkic_b.t_psi_order as t
+                left join dkic_b.t_mst_customer tmc on t.cus_id = tmc.cus_id
+        <include refid="Condition"/>
+    </select>
+
     <sql id="Base_Column_List_Item_Response_Join">
         toi.item_id AS toi_item_id,
         t.order_id AS toi_order_id,

+ 6 - 10
src/main/java/com/dk/mdm/model/pojo/mst/GoodsSku.java

@@ -39,7 +39,7 @@ public class GoodsSku extends PageInfo<GoodsSku> implements Serializable {
      * 错误信息
      */
     @Excel(name = "错误提示")
-    @ApiModelProperty(value = "错误提示")
+    @TableField(exist = false)
     private String errorMessage;
 
     /*
@@ -101,39 +101,35 @@ public class GoodsSku extends PageInfo<GoodsSku> implements Serializable {
      * 品牌名称
      */
     @Excel(name = "商品品牌")
-    @ApiModelProperty(value = "商品品牌")
-    @TableField(typeHandler = UuidTypeHandler.class)
+    @TableField(exist = false)
     private String brandName;
 
     /**
      * 商品种类
      */
     @Excel(name = "商品种类")
-    @ApiModelProperty(value = "商品种类")
-    @TableField(typeHandler = UuidTypeHandler.class)
+    @TableField(exist = false)
     private String categoryName;
 
     /**
      * 计量单位
      */
     @Excel(name = "计量单位")
-    @ApiModelProperty(value = "计量单位")
-    @TableField(typeHandler = UuidTypeHandler.class)
+    @TableField(exist = false)
     private String unitName;
 
     /**
      * 辅助单位
      */
     @Excel(name = "辅助单位")
-    @ApiModelProperty(value = "辅助单位")
-    @TableField(typeHandler = UuidTypeHandler.class)
+    @TableField(exist = false)
     private String subUnitName;
 
     /**
      * 商品系列
      */
     @Excel(name = "商品系列")
-    @ApiModelProperty(value = "商品系列")
+    @TableField(exist = false)
     private String seriesName;
 
     /**

+ 3 - 3
src/main/java/com/dk/mdm/model/pojo/sale/Order.java

@@ -341,10 +341,10 @@ public class Order extends PageInfo<Order> implements Serializable {
     private Integer cpId;
 
     /**
-     * 实金额
+     * 实金额
      */
-    @Excel(name = "实金额")
-    @ApiModelProperty(value = "实金额")
+    @Excel(name = "实金额")
+    @ApiModelProperty(value = "实金额")
     private BigDecimal factAmt;
 
     /**

+ 6 - 12
src/main/java/com/dk/mdm/model/pojo/sale/OrderItem.java

@@ -248,25 +248,19 @@ public class OrderItem extends PageInfo<OrderItem> implements Serializable {
     private Integer decimalPlaces;
 
     /**
-     * 实际单价
+     * 优惠后单价
      */
-    @Excel(name = "实际单价")
-    @ApiModelProperty(value = "实际单价")
+    @Excel(name = "优惠后单价")
+    @ApiModelProperty(value = "优惠后单价")
     private BigDecimal factPrice;
 
     /**
-     * 实际金额
+     * 优惠后金额
      */
-    @Excel(name = "实际金额")
-    @ApiModelProperty(value = "实际金额")
+    @Excel(name = "优惠后金额")
+    @ApiModelProperty(value = "优惠后金额")
     private BigDecimal factAmt;
 
-    /**
-     * 优惠金额
-     */
-    @Excel(name = "优惠金额")
-    @ApiModelProperty(value = "优惠金额")
-    private BigDecimal discAmt;
 
     /**
      * 使用位置

+ 6 - 13
src/main/java/com/dk/mdm/model/response/sale/OrderItemResponse.java

@@ -384,27 +384,20 @@ public class OrderItemResponse extends PageInfo<OrderItemResponse> implements Se
 
 
     /**
-     * 实际单价
+     * 优惠后单价
      */
-    @Excel(name = "实际单价")
-    @ApiModelProperty(value = "实际单价")
+    @Excel(name = "优惠后单价")
+    @ApiModelProperty(value = "优惠后单价")
     private BigDecimal factPrice;
 
     /**
-     * 实际金额
+     * 优惠后金额
      */
-    @Excel(name = "实际金额")
-    @ApiModelProperty(value = "实际金额")
+    @Excel(name = "优惠后金额")
+    @ApiModelProperty(value = "优惠后金额")
     private BigDecimal factAmt;
 
     /**
-     * 优惠金额
-     */
-    @Excel(name = "优惠金额")
-    @ApiModelProperty(value = "优惠金额")
-    private BigDecimal discAmt;
-
-    /**
      * 使用位置
      */
     @Excel(name = "使用位置")

+ 3 - 3
src/main/java/com/dk/mdm/model/response/sale/OrderResponse.java

@@ -349,10 +349,10 @@ public class OrderResponse extends PageInfo<OrderResponse> implements Serializab
     private Boolean flgValid;
 
     /**
-     * 实金额
+     * 实金额
      */
-    @Excel(name = "实金额")
-    @ApiModelProperty(value = "实金额")
+    @Excel(name = "实金额")
+    @ApiModelProperty(value = "实金额")
     private BigDecimal factAmt;
 
     /**

+ 4 - 11
src/main/java/com/dk/mdm/model/vo/sale/OrderItemVO.java

@@ -255,25 +255,18 @@ public class OrderItemVO extends PageInfo<OrderItemVO> implements Serializable {
 
 
     /**
-     * 实际单价
+     * 优惠后单价
      */
-    @ApiModelProperty(value = "实际单价")
+    @ApiModelProperty(value = "优惠后单价")
     private BigDecimal factPrice;
 
     /**
-     * 实际金额
+     * 优惠后金额
      */
-    @ApiModelProperty(value = "实际金额")
+    @ApiModelProperty(value = "优惠后金额")
     private BigDecimal factAmt;
 
     /**
-     * 优惠金额
-     */
-    @ApiModelProperty(value = "优惠金额")
-    private BigDecimal discAmt;
-
-
-    /**
      * 使用位置
      */
     @ApiModelProperty(value = "使用位置")

+ 1 - 1
src/main/java/com/dk/mdm/model/vo/sale/OrderVO.java

@@ -383,7 +383,7 @@ public class OrderVO extends PageInfo<OrderVO> implements Serializable {
     @ApiModelProperty(value = "自动办理参数")
     private Boolean flgHandleSetting;
 
-    @ApiModelProperty(value = "实金额")
+    @ApiModelProperty(value = "实金额")
     private BigDecimal factAmt;
 
     @ApiModelProperty(value = "优惠金额")

+ 1 - 0
src/main/java/com/dk/mdm/service/common/CommonService.java

@@ -163,6 +163,7 @@ public class CommonService extends BaseService<Map<String, Object>> {
     public ResponseResultVO<List<Map<String, Object>>> getDataKind(Map<String, Object> param) {
         // 获取系统基础数据
         List<Map<String, Object>> list = commonMapper.getDataKind(param);
+
         return ResponseResultUtil.success(list);
     }
 

+ 24 - 28
src/main/java/com/dk/mdm/service/ivt/inventory/InventoryService.java

@@ -101,34 +101,7 @@ public class InventoryService extends BaseService<Inventory> {
      */
     @Pagination
     public ResponseResultVO<PageList<InventoryResponse>> selectByCond(InventoryQuery inboundQuery) {
-
-        ResponseResultVO<PageList<InventoryResponse>> pageListResponseResultVO = super.mergeListWithCount(inboundQuery, inventoryMapper.selectByCond(inboundQuery), inventoryMapper.countByCond(inboundQuery));
-        if (inboundQuery.getWinning()!=null && inboundQuery.getWinning() == true){
-            PageList<InventoryResponse> data = pageListResponseResultVO.getData();
-            List<InventoryResponse> list = data.getList();
-            List<InventoryResponse> newList = list.stream().filter(item ->
-                    (
-                            item.getWarningLowerLimit()!= 0
-                            || item.getWarningUpperLimit() != 0)
-                            && (item.getInvQty().longValue()>item.getWarningLowerLimit()
-                            || item.getInvQty().longValue()>item.getWarningUpperLimit())
-                    ).collect(Collectors.toList());
-            newList.forEach(item -> {
-                int invQty = item.getInvQty().intValue();
-                Long warningLowerLimit = item.getWarningLowerLimit();
-                Long warningUpperLimit = item.getWarningUpperLimit();
-                if (invQty > warningLowerLimit){
-                    item.setWarningMsg("超出警戒上限");
-                }
-                if (invQty > warningUpperLimit){
-                    item.setWarningMsg("超出警戒下限");
-                }
-            });
-            data.setList(newList);
-            pageListResponseResultVO.setData(data);
-        }
-
-        return pageListResponseResultVO;
+        return super.mergeListWithCount(inboundQuery, inventoryMapper.selectByCond(inboundQuery), inventoryMapper.countByCond(inboundQuery));
     }
 
 
@@ -2238,4 +2211,27 @@ public class InventoryService extends BaseService<Inventory> {
     }
 
 
+    public ResponseResultVO<PageList<InventoryResponse>> warningSelectByCond(InventoryQuery inboundQuery) {
+        inboundQuery.setStart((inboundQuery.getCurrentPage() - 1) * inboundQuery.getPageSize());
+        inboundQuery.setEnd(inboundQuery.getPageSize());
+        ResponseResultVO<PageList<InventoryResponse>> pageListResponseResultVO = super.mergeListWithCount(
+                inboundQuery,
+                inventoryMapper.warningSelectByCond(inboundQuery),
+                inventoryMapper.warningCountByCond(inboundQuery));
+        PageList<InventoryResponse> data = pageListResponseResultVO.getData();
+        List<InventoryResponse> list = data.getList();
+        list.forEach(item -> {
+            int invQty = item.getInvQty().intValue();
+            Long warningLowerLimit = item.getWarningLowerLimit();
+            Long warningUpperLimit = item.getWarningUpperLimit();
+            if (invQty > warningLowerLimit){
+                item.setWarningMsg("超出警戒上限");
+            }
+            if (invQty > warningUpperLimit){
+                item.setWarningMsg("超出警戒下限");
+            }
+        });
+
+        return pageListResponseResultVO;
+    }
 }

+ 29 - 10
src/main/java/com/dk/mdm/service/mst/GoodsSkuService.java

@@ -187,56 +187,75 @@ public class GoodsSkuService extends BaseService<GoodsSku> {
 			goodsSku.setCpId(cpId);
 			goodsSku.setErrorMessage("");
 			//TODO 校验规则
+			//商品编号不能为空
+			if(goodsSku.getSkuCode()==null){
+				goodsSku.setErrorMessage("商品编号不能为空,");
+				importMessage = true;
+			}
+			//商品型号不能为空
+			if(goodsSku.getSkuModel()==null){
+				goodsSku.setErrorMessage("商品型号不能为空,");
+				importMessage = true;
+			}
 			//品牌
-			if (goodsSku.getBrandName()!=null ||goodsSku.getBrandName()!= "") {
+			if (goodsSku.getBrandName()!=null) {
 				String brandName = goodsSku.getBrandName();
 				GoodsBrandResponse goodsBrandResponse = goodsBrandMapper.selectByUuId(new GoodsBrandQuery().setBrandName(brandName).setCpId(goodsSku.getCpId()));
 				if(goodsBrandResponse == null){
-					goodsSku.setErrorMessage("1.商品品牌填写错误");
+					goodsSku.setErrorMessage("商品品牌填写错误,");
 					importMessage = true;
 				}else{
 					goodsSku.setBrandId(goodsBrandResponse.getBrandId());
 				}
+			}else{
+				goodsSku.setErrorMessage("商品品牌不能为空,");
+				importMessage = true;
 			}
 			//种类
-			if (goodsSku.getCategoryName()!=null ||goodsSku.getCategoryName()!= "") {
+			if (goodsSku.getCategoryName()!=null) {
 				String CatagoryName = goodsSku.getCategoryName();
 				GoodsCategoryResponse goodsCategoryResponse = goodsCategoryMapper.selectByUuId(new GoodsCategoryQuery().setCatName(CatagoryName).setCpId(goodsSku.getCpId()));
 				if(goodsCategoryResponse == null){
-					goodsSku.setErrorMessage(goodsSku.getErrorMessage() + "2.商品种类填写错误");
+					goodsSku.setErrorMessage(goodsSku.getErrorMessage() + "商品种类填写错误,");
 					importMessage = true;
 				}else{
 					goodsSku.setCategoryId(goodsCategoryResponse.getCatId());
 				}
+			}else{
+				goodsSku.setErrorMessage(goodsSku.getErrorMessage() + "商品种类不能为空,");
+				importMessage = true;
 			}
 			//计量单位
-			if (goodsSku.getUnitName()!=null ||goodsSku.getUnitName()!= "") {
+			if (goodsSku.getUnitName()!=null) {
 				String unintName = goodsSku.getUnitName();
 				UnitResponse unitResponse = unitMapper.selectByUuId(new UnitQuery().setUnitName(unintName).setCpId(goodsSku.getCpId()));
 				if(unitResponse == null){
-					goodsSku.setErrorMessage(goodsSku.getErrorMessage() + "3.计量单位填写错误");
+					goodsSku.setErrorMessage(goodsSku.getErrorMessage() + "计量单位填写错误,");
 					importMessage = true;
 				}else{
 					goodsSku.setUnitId(unitResponse.getUnitId());
 				}
+			}else{
+				goodsSku.setErrorMessage(goodsSku.getErrorMessage() + "计量单位不能为空,");
+				importMessage = true;
 			}
 			//辅助单位
-			if (goodsSku.getSubUnitName()!=null ||goodsSku.getSubUnitName()!= "") {
+			if (goodsSku.getSubUnitName()!=null) {
 				String subUnintName = goodsSku.getSubUnitName();
 				UnitResponse unitResponse = unitMapper.selectByUuId(new UnitQuery().setUnitName(subUnintName).setCpId(goodsSku.getCpId()));
 				if(unitResponse == null){
-					goodsSku.setErrorMessage(goodsSku.getErrorMessage()  + "4.辅助单位填写错误");
+					goodsSku.setErrorMessage(goodsSku.getErrorMessage()  + "辅助单位填写错误,");
 					importMessage = true;
 				}else{
 					goodsSku.setSubUnitId(unitResponse.getUnitId());
 				}
 			}
 			//商品系列
-			if (goodsSku.getSeriesName()!=null ||goodsSku.getSeriesName()!= "") {
+			if (goodsSku.getSeriesName()!=null) {
 				String seriesName = goodsSku.getSeriesName();
 				GoodsSeriesResponse goodsSeriesResponse = goodsSeriesMapper.selectByUuId(new GoodsSeriesQuery().setSeriesName(seriesName).setCpId(goodsSku.getCpId()));
 				if(goodsSeriesResponse == null){
-					goodsSku.setErrorMessage(goodsSku.getErrorMessage() + "5.商品系列填写错误");
+					goodsSku.setErrorMessage(goodsSku.getErrorMessage() + "商品系列填写错误,");
 					importMessage = true;
 				}else{
 					goodsSku.setSubUnitId(goodsSeriesResponse.getSeriesId());

+ 81 - 22
src/main/java/com/dk/mdm/service/mst/StaffService.java

@@ -29,6 +29,7 @@ import com.dk.mdm.model.query.mst.GoodsCategoryQuery;
 import com.dk.mdm.model.query.mst.StaffQuery;
 import com.dk.common.model.response.mst.StaffResponse;
 import com.dk.common.model.vo.mst.StaffVO;
+import com.dk.mdm.model.response.mst.ComMenuResponse;
 import com.dk.mdm.model.vo.mst.ComMenuVO;
 import com.dk.mdm.service.common.CommonService;
 import lombok.extern.slf4j.Slf4j;
@@ -120,7 +121,6 @@ public class StaffService extends BaseService<Staff> {
     @Autowired
     PrintLayoutMapper printLayoutMapper;
 
-
     /**
      * @desc : 条件查询
      * @author : 姜永辉
@@ -159,7 +159,8 @@ public class StaffService extends BaseService<Staff> {
         // 转化实体
         Staff staff = staffConvert.convertToPo(staffVO);
         // 获取当前公司的cpId
-        Integer cpId = authUtils.getStaff().getCpId();
+        StaffEntity staffEntity = authUtils.getStaff();
+        Integer cpId = staffEntity.getCpId();
         // 校验同一个公司的电话不能重复
         StaffQuery staffQuery = new StaffQuery();
         staffQuery.setStaffPhone(staff.getStaffPhone());
@@ -185,8 +186,15 @@ public class StaffService extends BaseService<Staff> {
                         ErrorCodeEnum.USER_REGISTER_ERROR.getMessage());
             } else {
                 Map<String, Object> mp = (Map<String, Object>) resultMaxnum.getData();
-                int intWebMaxnum = Integer.parseInt(mp.get("web_max_num") + "");
-                int intWxMaxnum = Integer.parseInt(mp.get("wx_max_num") + "");
+                int intWebMaxnum =0;
+                if(mp.get("web_max_num") != null ){
+                    intWebMaxnum =  Integer.parseInt(mp.get("web_max_num") + "");
+                }
+
+                int intWxMaxnum = 0;
+                if(mp.get("wx_max_num") != null ){
+                    intWxMaxnum =  Integer.parseInt(mp.get("wx_max_num") + "");
+                }
                 staffQuery = new StaffQuery();
                 staffQuery.setFlgCanLogin(true);
                 staffQuery.setCpId(cpId);
@@ -215,6 +223,29 @@ public class StaffService extends BaseService<Staff> {
         staff.setStaffId(codeMap.get("outId").toString());
 //        staff.setStaffCode(codeMap.get("outNote").toString());
         super.insert(staff);
+
+        // 常用菜单的插入
+        if (staffVO.getFlgCanLogin() != null && staffVO.getFlgCanLogin()) {
+            ResponseResultVO<?> comMenuRes = companyFeign.getComMenu(staffEntity.getGradeCode());
+            if (comMenuRes.getCode() == ResponseCodeEnum.SUCCESS.getCode()) {
+                List<Map<String, Object>> comMenuMapList = (List<Map<String, Object>>) comMenuRes.getData();
+
+                List<ComMenu> listCom = new ArrayList<>();
+                if (comMenuMapList != null && comMenuMapList.size() > 0) {
+                    for (int i = 0; i < comMenuMapList.size(); i++) {
+                        Map<String, Object> m = comMenuMapList.get(i);
+                        ComMenu comMenu = new ComMenu();
+                        comMenu.setMenuUuid(m.get("menuUuid").toString());
+                        comMenu.setStaffId(staff.getStaffId());
+                        comMenu.setAppCode(m.get("appCode").toString());
+                        comMenu.setDisplayNo((Integer) m.get("displayNo"));
+                        comMenu.setCpId(cpId);
+                        listCom.add(comMenu);
+                    }
+                    comMenuMapper.insertBatch(listCom);
+                }
+            }
+        }
         // 讲电话和名称插入微信用户表里
         Map<String, Object> collectQuery = new HashMap<>();
         collectQuery.put("currentCp", staff.getCpId());
@@ -292,24 +323,39 @@ public class StaffService extends BaseService<Staff> {
         Integer cpId = Integer.parseInt(listCom.get(0).get("cpId").toString());
         String staffId = listCom.get(0).get("staffId").toString();
 
+        List<Map<String, Object>> listComMenu = map.get("listComMenu");
+        List<ComMenu> listC = new ArrayList<>();
+        if (listComMenu != null && listComMenu.size() > 0) {
+            for (int i = 0; i < listComMenu.size(); i++) {
+                Map<String, Object> m = listComMenu.get(i);
+                ComMenu comMenu = new ComMenu();
+                comMenu.setMenuUuid(m.get("menuUuid").toString());
+                comMenu.setAppCode(m.get("appCode").toString());
+                comMenu.setDisplayNo((Integer) m.get("displayNo"));
+                comMenu.setCpId(cpId);
+                comMenu.setStaffId(staffId);
+                listC.add(comMenu);
+            }
+            comMenuMapper.insertBatch(listC);
+        }
         // 插入常用功能 标准版 插入 销售出库 库存查询 商品档案
         if (Constant.STD.equals(gradeCode)) {
-            List<String> objectCodeList = new ArrayList<>();
-            // 商品属性
-            objectCodeList.add("goods-attr");
-            // 商品档案
-            objectCodeList.add("goods");
-            // 销售订单
-            objectCodeList.add("order");
-            // 销售出库
-            objectCodeList.add("order-out");
-            // 库存查询
-            objectCodeList.add("ivt-detail-report");
-
-            ComMenuVO comMenuVO = new ComMenuVO();
-            comMenuVO.setCpId(cpId).setStaffId(staffId).setAppCode(Constant.AppCode.WEIXIN.getCode())
-                    .setObjectCodeList(objectCodeList);
-            comMenuMapper.saveByCompany(comMenuVO);
+//            List<String> objectCodeList = new ArrayList<>();
+//            // 商品属性
+//            objectCodeList.add("goods-attr");
+//            // 商品档案
+//            objectCodeList.add("goods");
+//            // 销售订单
+//            objectCodeList.add("order");
+//            // 销售出库
+//            objectCodeList.add("order-out");
+//            // 库存查询
+//            objectCodeList.add("ivt-detail-report");
+//
+//            ComMenuVO comMenuVO = new ComMenuVO();
+//            comMenuVO.setCpId(cpId).setStaffId(staffId).setAppCode(Constant.AppCode.WEIXIN.getCode())
+//                    .setObjectCodeList(objectCodeList);
+//            comMenuMapper.saveByCompany(comMenuVO);
 
             // 系统参数
             List<SettingValue> settingValueList = new ArrayList<>();
@@ -340,6 +386,10 @@ public class StaffService extends BaseService<Staff> {
                 role.setFlgNolimitFun(true);
                 role.setFlgNolimitPvw(true);
                 role.setFlgNolimitSen(true);
+            }else{
+                role.setFlgNolimitFun(false);
+                role.setFlgNolimitPvw(false);
+                role.setFlgNolimitSen(false);
             }
             listR.add(role);
         }
@@ -590,8 +640,15 @@ public class StaffService extends BaseService<Staff> {
             } else {
                 if (staffResponseOld.getFlgCanLogin() != staffVO.getFlgCanLogin()) {
                     Map<String, Object> mp = (Map<String, Object>) resultMaxnum.getData();
-                    int intWebMaxnum = Integer.parseInt(mp.get("web_max_num") + "");
-                    int intWxMaxnum = Integer.parseInt(mp.get("wx_max_num") + "");
+                    int intWebMaxnum =0;
+                    if(mp.get("web_max_num") != null ){
+                        intWebMaxnum =  Integer.parseInt(mp.get("web_max_num") + "");
+                    }
+
+                    int intWxMaxnum = 0;
+                    if(mp.get("wx_max_num") != null ){
+                        intWxMaxnum =  Integer.parseInt(mp.get("wx_max_num") + "");
+                    }
                     StaffQuery staffQueryf = new StaffQuery();
                     staffQueryf.setFlgCanLogin(true);
                     staffQueryf.setCpId(cpId);
@@ -789,6 +846,8 @@ public class StaffService extends BaseService<Staff> {
         dic.put("dataKindList", commonMapper.getDataKind(param));
         dic.put("settingValue", allSettingValue);
         dic.put("staff", staff);
+        // 判断是否到期 返回服务器的时间
+        dic.put("nowDate", LocalDate.now());
         return ResponseResultUtil.success(dic);
     }
 

+ 63 - 0
src/main/java/com/dk/mdm/service/report/ReportService.java

@@ -729,6 +729,8 @@ public class ReportService {
      */
     public ResponseResultVO<List<Map<String, Object>>> getCusRecPayReportItem(Map<String, Object> params) {
         List<Map<String, Object>> items = reportMapper.getCusRecPayReportItemByUser(params);
+        params.put("start", (Integer.parseInt(params.get("currentPage").toString()) - 1) * Integer.parseInt(params.get("pageSize").toString()));
+        params.put("end", Integer.parseInt(params.get("pageSize").toString()));
         List<Map<String, Object>> arrears = reportMapper.getUserArrears(params);
         // 判断类型
         for (Map<String, Object> item : items) {
@@ -940,4 +942,65 @@ public class ReportService {
         }
         return returnStr;
     }
+
+    /**
+     * @desc   : 查询销售利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    public ResponseResultVO<Map<String, Object>> getSaleProfit(Map<String, Object> param) {
+        Map<String, Object> res = new HashMap<>();
+        res.put("profit", reportMapper.getSaleProfit(param));
+        res.put("dateProfit", reportMapper.getSaleProfitGroupByDate(param));
+        param.put("limit", true);
+        res.put("orgProfit", reportMapper.getSaleProfitGroupByOrg(param));
+        res.put("staffProfit", reportMapper.getSaleProfitGroupByStaff(param));
+        res.put("skuProfit", reportMapper.getSaleProfitGroupBySku(param));
+        return ResponseResultUtil.success(res);
+    }
+
+    /**
+     * @desc   : 查询销售利润 按日或按月
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+//    public ResponseResultVO<List<Map<String, Object>>> getSaleProfitGroupByDate(Map<String, Object> param) {
+//        return ResponseResultUtil.success(reportMapper.getSaleProfitGroupByDate(param));
+//    }
+
+    /**
+     * @desc   : 查询部门利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    public ResponseResultVO<Map<String, Object>> getSaleProfitGroupByOrg(Map<String, Object> param) {
+        Map<String, Object> res = new HashMap<>();
+        res.put("profit", reportMapper.getSaleProfit(param));
+        res.put("orgProfit", reportMapper.getSaleProfitGroupByOrg(param));
+        return ResponseResultUtil.success(res);
+    }
+
+    /**
+     * @desc   : 查询业务员利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    public ResponseResultVO<Map<String, Object>> getSaleProfitGroupByStaff(Map<String, Object> param) {
+        Map<String, Object> res = new HashMap<>();
+        res.put("profit", reportMapper.getSaleProfit(param));
+        res.put("orgProfit", reportMapper.getSaleProfitGroupByStaff(param));
+        return ResponseResultUtil.success(res);
+    }
+
+    /**
+     * @desc   : 查询商品利润
+     * @author : 洪旭东
+     * @date   : 2024-06-07 16:48
+     */
+    public ResponseResultVO<Map<String, Object>> getSaleProfitGroupBySku(Map<String, Object> param) {
+        Map<String, Object> res = new HashMap<>();
+        res.put("profit", reportMapper.getSaleProfit(param));
+        res.put("orgProfit", reportMapper.getSaleProfitGroupBySku(param));
+        return ResponseResultUtil.success(res);
+    }
 }

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

@@ -150,7 +150,7 @@ public class OrderService extends BaseService<Order> {
     @Pagination
     public ResponseResultVO<PageList<OrderResponse>> selectByCond(OrderQuery orderQuery) {
         return super.mergeListWithCount(orderQuery, orderMapper.selectByCond(orderQuery),
-                orderMapper.countByCond(orderQuery));
+                orderMapper.countByCondForSelectByCond(orderQuery));
     }
 
     /**