Эх сурвалжийг харах

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

changhaoning 1 жил өмнө
parent
commit
8ccb112437

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

@@ -407,8 +407,8 @@ sys.f_remove_zero(out_qty) as out_qty, out_amt, sys.f_remove_zero(return_qty) as
                t.sku_id,
                t.sku_id,
                tmgs.sku_images,
                tmgs.sku_images,
                tmgs.flg_sub_unit AS "flgSubUnit",
                tmgs.flg_sub_unit AS "flgSubUnit",
-               t.outing_box ,
-               t.outing_piece ,
+               t.outing_box + t.out_box  as outing_box,
+               sys.f_remove_zero(t.outing_piece + t.out_piece)  as outing_piece,
                t.out_box ,
                t.out_box ,
                t.out_piece ,
                t.out_piece ,
                tmgs.price_standard AS "priceStandard",
                tmgs.price_standard AS "priceStandard",

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

@@ -40,5 +40,12 @@ public interface DictionaryDataMapper extends BaseMapper<DictionaryData>{
     Integer updateBatchDictionaryDataDisplayNo(List<Map<String,Object>> dataIds);
     Integer updateBatchDictionaryDataDisplayNo(List<Map<String,Object>> dataIds);
     Integer updateFlgDefault(DictionaryDataQuery dictionaryDataQuery);
     Integer updateFlgDefault(DictionaryDataQuery dictionaryDataQuery);
 
 
+    /**
+     * @desc : 判断值是否重复
+     * @author : 周兴
+     * @date :  2024/6/19 9:39
+     */
+    Long checkValueDuplicated(DictionaryData dictionaryData);
+
 }
 }
 
 

+ 43 - 32
src/main/java/com/dk/mdm/mapper/mst/DictionaryDataMapper.xml

@@ -5,32 +5,34 @@
     <!-- 通用设置 -->
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
     <sql id="Base_Column_List">
-        data_id, dict_code, data_value, display_no, 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, sys_code, data_code, flg_default
+        data_id
+        , dict_code, data_value, display_no, 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, sys_code, data_code, flg_default
     </sql>
     </sql>
 
 
     <!-- 通用查询映射结果 -->
     <!-- 通用查询映射结果 -->
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.DictionaryData">
     <resultMap id="BaseResultMap" type="com.dk.mdm.model.pojo.mst.DictionaryData">
         <id column="data_id" property="dataId"/>
         <id column="data_id" property="dataId"/>
-                <result column="dict_code" property="dictCode"/>
-                <result column="data_value" property="dataValue"/>
-                <result column="display_no" property="displayNo"/>
-                <result column="remarks" property="remarks"/>
-                <result column="flg_valid" property="flgValid"/>
-                <result column="cp_id" property="cpId"/>
-            <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
-                <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
-            <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
-                <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
-                <result column="op_app_code" property="opAppCode"/>
-            <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
-                <result column="op_db_user" property="opDbUser"/>
-                <result column="sys_code" property="sysCode"/>
-                <result column="data_code" property="dataCode"/>
-                <result column="flg_default" property="flgDefault"/>
+        <result column="dict_code" property="dictCode"/>
+        <result column="data_value" property="dataValue"/>
+        <result column="display_no" property="displayNo"/>
+        <result column="remarks" property="remarks"/>
+        <result column="flg_valid" property="flgValid"/>
+        <result column="cp_id" property="cpId"/>
+        <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
+        <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
+        <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
+        <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
+        <result column="op_app_code" property="opAppCode"/>
+        <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
+        <result column="op_db_user" property="opDbUser"/>
+        <result column="sys_code" property="sysCode"/>
+        <result column="data_code" property="dataCode"/>
+        <result column="flg_default" property="flgDefault"/>
     </resultMap>
     </resultMap>
 
 
     <sql id="Base_Column_List_Response">
     <sql id="Base_Column_List_Response">
-        data_id, dict_code, data_value, display_no, remarks, flg_valid, cp_id, data_code, flg_default,sys_code
+        data_id
+        , dict_code, data_value, display_no, remarks, flg_valid, cp_id, data_code, flg_default,sys_code
     </sql>
     </sql>
 
 
     <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mst.DictionaryDataResponse">
     <resultMap id="BaseResultMapResponse" type="com.dk.mdm.model.response.mst.DictionaryDataResponse">
@@ -101,10 +103,10 @@
                 AND flg_valid =
                 AND flg_valid =
                 any(#{flgValidList, typeHandler=BooleanListTypeHandler})
                 any(#{flgValidList, typeHandler=BooleanListTypeHandler})
             </if>
             </if>
-            <if  test="searchText != null">
-                AND (data_value  like concat('%', my_ex.likequery(#{searchText}) , '%')
-                OR  dict_code  like concat('%', my_ex.likequery(#{searchText}) , '%')
-                OR  remarks like concat('%', my_ex.likequery(#{searchText}) , '%')
+            <if test="searchText != null">
+                AND (data_value like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR dict_code like concat('%', my_ex.likequery(#{searchText}) , '%')
+                OR remarks like concat('%', my_ex.likequery(#{searchText}) , '%')
                 )
                 )
             </if>
             </if>
 
 
@@ -139,11 +141,9 @@
         <include refid="Condition"/>
         <include refid="Condition"/>
     </select>
     </select>
     <select id="countByCondMoneyAccount" resultType="Long">
     <select id="countByCondMoneyAccount" resultType="Long">
-        SELECT
-            count(1)
-        FROM
-            dkic_b.t_mst_money_account
-                LEFT JOIN dkic_b.t_mst_dictionary_data dd ON mac_type = dd.data_id
+        SELECT count(1)
+        FROM dkic_b.t_mst_money_account
+                 LEFT JOIN dkic_b.t_mst_dictionary_data dd ON mac_type = dd.data_id
         where dd.data_id = #{id}::uuid
         where dd.data_id = #{id}::uuid
     </select>
     </select>
 
 
@@ -155,6 +155,18 @@
         WHERE data_id = #{id}::uuid
         WHERE data_id = #{id}::uuid
     </select>
     </select>
 
 
+    <!-- 判断名称是否重复 -->
+    <select id="checkValueDuplicated" resultType="Long">
+        SELECT count(1)
+        FROM dkic_b.t_mst_dictionary_data
+        WHERE dict_code = #{dictCode}
+        AND cp_id = #{cpId}
+        AND data_value = #{dataValue}
+        <if test="dataId != null  and dataId != ''">
+            AND data_id != #{dataId} ::uuid
+        </if>
+    </select>
+
     <!-- 根据主键锁定表t_mst_dictionary_data的一行数据 -->
     <!-- 根据主键锁定表t_mst_dictionary_data的一行数据 -->
     <select id="selectByIdForUpdate" resultMap="BaseResultMap">
     <select id="selectByIdForUpdate" resultMap="BaseResultMap">
         SELECT
         SELECT
@@ -207,8 +219,6 @@
     </insert>
     </insert>
 
 
 
 
-
-
     <update id="updateBatchDictionaryDataDisplayNo">
     <update id="updateBatchDictionaryDataDisplayNo">
         <foreach collection="list" index="index" item="item" separator=";">
         <foreach collection="list" index="index" item="item" separator=";">
             UPDATE dkic_b.t_mst_dictionary_data
             UPDATE dkic_b.t_mst_dictionary_data
@@ -221,8 +231,9 @@
 
 
     <update id="updateFlgDefault">
     <update id="updateFlgDefault">
         UPDATE dkic_b.t_mst_dictionary_data
         UPDATE dkic_b.t_mst_dictionary_data
-        SET
-            flg_default = false
-        WHERE      dict_code = #{dictCode} AND  cp_id = #{cpId} and (flg_default = true OR flg_default is null)
+        SET flg_default = false
+        WHERE dict_code = #{dictCode}
+          AND cp_id = #{cpId}
+          and (flg_default = true OR flg_default is null)
     </update>
     </update>
 </mapper>
 </mapper>

+ 18 - 6
src/main/java/com/dk/mdm/mapper/report/ReportMapper.xml

@@ -3074,10 +3074,16 @@
         select
         select
         <include refid="getSaleProfitInOutBound"/>
         <include refid="getSaleProfitInOutBound"/>
         from dkic_b.t_psi_in_out_record tpr
         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 test="orgIds!=null and orgIds.size()>0">
+            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
+        </if>
+        <include refid="getSaleProfitCond"/>
+        <if test="orgIds!=null and orgIds.size()>0">
+            and (
+            (tpo.org_id = any(#{orgIds, typeHandler=UuidListTypeHanlder}) and tpi.org_id is null)
+            or (tpi.org_id = any(#{orgIds, typeHandler=UuidListTypeHanlder}) and tpo.org_id is null)
+            )
         </if>
         </if>
         ) t
         ) t
     </select>
     </select>
@@ -3137,6 +3143,12 @@
         left join dkic_b.t_psi_inbound tpi on tpi.into_id = biznis_id
         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
         left join dkic_b.t_psi_outbound tpo on tpo.out_id = biznis_id
         <include refid="getSaleProfitCond"/>
         <include refid="getSaleProfitCond"/>
+        <if test="orgIds!=null and orgIds.size()>0">
+            and (
+            (tpo.org_id = any(#{orgIds, typeHandler=UuidListTypeHanlder}) and tpi.org_id is null)
+            or (tpi.org_id = any(#{orgIds, typeHandler=UuidListTypeHanlder}) and tpo.org_id is null)
+            )
+        </if>
         group by coalesce(tpi.staff_id, tpo.staff_id)) t
         group by coalesce(tpi.staff_id, tpo.staff_id)) t
         ) tt
         ) tt
         left join dkic_b.t_mst_staff tms on tms.staff_id = tt.staff_id
         left join dkic_b.t_mst_staff tms on tms.staff_id = tt.staff_id
@@ -3180,10 +3192,10 @@
             order by tt.profit desc
             order by tt.profit desc
         </if>
         </if>
         <if test="orderBy != null and orderBy=='rateAsc'">
         <if test="orderBy != null and orderBy=='rateAsc'">
-            order by tt.profitRate
+            order by tt."profitRate"
         </if>
         </if>
         <if test="orderBy != null and orderBy=='rateDsc'">
         <if test="orderBy != null and orderBy=='rateDsc'">
-            order by tt.profitRate desc
+            order by tt."profitRate" desc
         </if>
         </if>
         <if test="limit!=null and limit">
         <if test="limit!=null and limit">
             limit 5
             limit 5

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

@@ -343,8 +343,8 @@
                t.item_index,
                t.item_index,
                t.sku_id,
                t.sku_id,
                tmgs.sku_code                              as "skuCode",
                tmgs.sku_code                              as "skuCode",
-               tmgs.sku_model                             as "skuModel",
-               tmgs.sku_name                              as "skuName",
+               t.sku_model                             as "skuModel",
+               t.sku_name                              as "skuName",
                tmgs.sku_images AS "skuImages",
                tmgs.sku_images AS "skuImages",
                t.pack_box  ,
                t.pack_box  ,
                sys.f_remove_zero(t.item_qty)              as "orderQty",
                sys.f_remove_zero(t.item_qty)              as "orderQty",

+ 9 - 4
src/main/java/com/dk/mdm/mapper/sale/OrderMapper.xml

@@ -211,6 +211,7 @@
         <result column="flg_handle_setting" property="flgHandleSetting"/>
         <result column="flg_handle_setting" property="flgHandleSetting"/>
         <result column="channelName" property="channelName"/>
         <result column="channelName" property="channelName"/>
         <result column="outbound_processing_flag" property="outboundProcessingFlag"/>
         <result column="outbound_processing_flag" property="outboundProcessingFlag"/>
+        <result column="categoryCount" property="categoryCount"/>
         <collection property="orderItemResponseList" resultMap="itemListMap" columnPrefix="list_"/>
         <collection property="orderItemResponseList" resultMap="itemListMap" columnPrefix="list_"/>
 
 
     </resultMap>
     </resultMap>
@@ -314,8 +315,8 @@
         toi.flg_valid AS list_flg_valid,
         toi.flg_valid AS list_flg_valid,
         toi.cp_id AS list_cp_id,
         toi.cp_id AS list_cp_id,
         tmgs.sku_code AS list_sku_code,
         tmgs.sku_code AS list_sku_code,
-        tmgs.sku_model AS list_sku_model,
-        tmgs.sku_name AS list_sku_name,
+        toi.sku_model AS list_sku_model,
+        toi.sku_name AS list_sku_name,
         tmgb.brand_name AS list_brand_name,
         tmgb.brand_name AS list_brand_name,
         tmgb.short_name AS list_short_name,
         tmgb.short_name AS list_short_name,
         tmgs.sku_images AS list_sku_images,
         tmgs.sku_images AS list_sku_images,
@@ -539,7 +540,8 @@
                makestaff.staff_name                              as "makeStaffName",
                makestaff.staff_name                              as "makeStaffName",
                t.make_time,
                t.make_time,
                t.cp_id,
                t.cp_id,
-               t.flg_valid
+               t.flg_valid,
+               t.fact_amt
         FROM dkic_b.t_psi_order as t
         FROM dkic_b.t_psi_order as t
                  left join dkic_b.t_mst_sale_channel tmsc on t.sales_channel = tmsc.channel_id
                  left join dkic_b.t_mst_sale_channel tmsc on t.sales_channel = tmsc.channel_id
                  left join dkic_b.t_mst_org tmo on t.org_id = tmo.org_id
                  left join dkic_b.t_mst_org tmo on t.org_id = tmo.org_id
@@ -1051,10 +1053,13 @@
         tmsc.channel_name as "channelName",
         tmsc.channel_name as "channelName",
 
 
         <include refid="Base_Column_List_Item_Response_Detail_Join"/>
         <include refid="Base_Column_List_Item_Response_Detail_Join"/>
+        ,(select count(DISTINCT tmgss.category_id) from dkic_b.t_psi_order_item ti
+                LEFT  JOIN dkic_b.t_mst_goods_sku tmgss ON tmgss.sku_id = ti.sku_id
+                where ti.order_id = t.order_id and ti.flg_valid) as "categoryCount"
         FROM dkic_b.t_psi_order as t
         FROM dkic_b.t_psi_order as t
         left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
         left join dkic_b.t_mst_customer tmc on tmc.cus_id = t.cus_id
         left join dkic_b.t_psi_order_item toi on toi.order_id  = t.order_id
         left join dkic_b.t_psi_order_item toi on toi.order_id  = t.order_id
-        inner join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id  = toi.sku_id
+        left join dkic_b.t_mst_goods_sku tmgs on tmgs.sku_id  = toi.sku_id
         left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id  = tmgs.brand_id
         left join dkic_b.t_mst_goods_brand tmgb on tmgb.brand_id  = tmgs.brand_id
         left join dkic_b.t_mst_org tmo on t.org_id = tmo.org_id
         left join dkic_b.t_mst_org tmo on t.org_id = tmo.org_id
         left join dkic_b.t_mst_sale_channel tmsc on t.sales_channel = tmsc.channel_id
         left join dkic_b.t_mst_sale_channel tmsc on t.sales_channel = tmsc.channel_id

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

@@ -429,6 +429,9 @@ public class OrderResponse extends PageInfo<OrderResponse> implements Serializab
     @ApiModelProperty(value = "开单并出库办理标识")
     @ApiModelProperty(value = "开单并出库办理标识")
     private Boolean outboundProcessingFlag;
     private Boolean outboundProcessingFlag;
 
 
+    @ApiModelProperty(value = "种类数")
+    private BigDecimal categoryCount;
+
 
 
     private static final long serialVersionUID = 1L;
     private static final long serialVersionUID = 1L;
 
 

+ 5 - 0
src/main/java/com/dk/mdm/model/vo/ivt/OutboundVO.java

@@ -48,6 +48,11 @@ public class OutboundVO{
     @Excel(name = "收款金额")
     @Excel(name = "收款金额")
     @ApiModelProperty(value = "收款金额")
     @ApiModelProperty(value = "收款金额")
     private BigDecimal sumAmtRec;
     private BigDecimal sumAmtRec;
+    /**
+     * 合计金额
+     */
+    @ApiModelProperty(value = "合计金额")
+    private BigDecimal sumAmount;
 
 
     /**
     /**
      * 实际金额
      * 实际金额

+ 60 - 18
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleOrderService.java

@@ -54,6 +54,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
 import java.math.BigDecimal;
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.time.LocalDate;
 import java.time.LocalDate;
 import java.util.HashMap;
 import java.util.HashMap;
 import java.util.List;
 import java.util.List;
@@ -148,12 +149,6 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     .setWhId(outboundItemVO.getWhId())
                     .setWhId(outboundItemVO.getWhId())
                     .setNonStdCode(outboundItemVO.getNonStdCode()));
                     .setNonStdCode(outboundItemVO.getNonStdCode()));
         }
         }
-        //库存不存在
-        if(inventoryResponse ==null){
-            //当前出库商品中在库存中不存在
-            throw new BaseBusinessException(ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getCode(),
-                    ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
-        }
         return inventoryResponse;
         return inventoryResponse;
     }
     }
     
     
@@ -193,19 +188,34 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                 if(outboundItemVO.getSkuId()!=null){
                 if(outboundItemVO.getSkuId()!=null){
                     //查询库存是否存在
                     //查询库存是否存在
                     InventoryResponse inventoryResponse = this.checkInventoryExist(outboundItemVO);
                     InventoryResponse inventoryResponse = this.checkInventoryExist(outboundItemVO);
-                    BigDecimal invQty = inventoryResponse.getInvQty().subtract(outboundItemVO.getOutingQty());
-                    // (库存量  大于等于  本次出库数量不用做任何处理)
-                    //库存量 小于  本次出库数量
-                    if (invQty.compareTo(BigDecimal.ZERO) < 0) {
-                        outboundItemVO.setOutingQty(inventoryResponse.getInvQty());
+                    if (inventoryResponse != null) {
+                        BigDecimal invQty = inventoryResponse.getInvQty().subtract(outboundItemVO.getOutingQty());
+                        // (库存量  大于等于  本次出库数量不用做任何处理)
+                        //库存量 小于  本次出库数量
+                        if (invQty.compareTo(BigDecimal.ZERO) < 0) {
+                            outboundItemVO.setOutingQty(inventoryResponse.getInvQty());
+                            //不够库存数量----新建出库中数量
+                            outboundItemVO.setNotEnoughInventoryQty(invQty.abs());
+                        }
+                    } else {
                         //不够库存数量----新建出库中数量
                         //不够库存数量----新建出库中数量
-                        outboundItemVO.setNotEnoughInventoryQty(invQty.abs());
+                        outboundItemVO.setNotEnoughInventoryQty(outboundItemVO.getOutingQty());
                     }
                     }
                 }
                 }
             }
             }
+            //过滤出库存量足够的数据
+            List<OutboundItemVO> itemList = outboundVO.getItemList().stream().filter(it -> it.getNotEnoughInventoryQty()==null ).collect(Collectors.toList());
+
             //region  过滤出不够出库的每条明细数量  ------新建出库中数据
             //region  过滤出不够出库的每条明细数量  ------新建出库中数据
             List<OutboundItemVO> outboundIngList = outboundVO.getItemList().stream().filter(it -> it.getNotEnoughInventoryQty()!=null && it.getNotEnoughInventoryQty().compareTo(BigDecimal.ZERO)>0).collect(Collectors.toList());
             List<OutboundItemVO> outboundIngList = outboundVO.getItemList().stream().filter(it -> it.getNotEnoughInventoryQty()!=null && it.getNotEnoughInventoryQty().compareTo(BigDecimal.ZERO)>0).collect(Collectors.toList());
             if(outboundIngList != null && outboundIngList.size()>0){
             if(outboundIngList != null && outboundIngList.size()>0){
+                //赋值箱片
+                for (OutboundItemVO outboundItemVO : outboundIngList) {
+                    //箱
+                    outboundItemVO.setOutingBox(Integer.valueOf(outboundItemVO.getOutingQty().divide(outboundItemVO.getPackBox(),RoundingMode.DOWN).toString()) );
+                    //片
+                    outboundItemVO.setOutingPiece(outboundItemVO.getOutingQty().remainder(outboundItemVO.getPackBox()));
+                }
                 outboundVO.setFlgAutoHandle(false);
                 outboundVO.setFlgAutoHandle(false);
                 outboundVO.setItemList(outboundIngList);
                 outboundVO.setItemList(outboundIngList);
                 //销售出库新建
                 //销售出库新建
@@ -215,8 +225,21 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
 
 
             //region  库存够扣减的明细  -----------新建已出库数据并扣减库存
             //region  库存够扣减的明细  -----------新建已出库数据并扣减库存
             //销售出库新建
             //销售出库新建
-            this.saleOrderOutboundInsert(outboundVO,true);
+            if (itemList!=null && itemList.size() > 0) {
+                for (OutboundItemVO outboundItemVO : itemList) {
+                    if(outboundItemVO.getSkuId()!=null){ //过滤外协品 外协品没有箱片
+                        //箱
+                        outboundItemVO.setOutBox(Integer.valueOf(outboundItemVO.getOutingQty().divide(outboundItemVO.getPackBox(),RoundingMode.DOWN).toString()) );
+                        //片
+                        outboundItemVO.setOutPiece(outboundItemVO.getOutingQty().remainder(outboundItemVO.getPackBox()));
+                    }
+                 }
+                outboundVO.setFlgAutoHandle(true);
+                outboundVO.setItemList(itemList);
+                this.saleOrderOutboundInsert(outboundVO, true);
+            }
             //endregion
             //endregion
+
         }
         }
     }
     }
     /*****************************************先判断库存*****************************************/
     /*****************************************先判断库存*****************************************/
@@ -297,6 +320,9 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                 inboundVO.setMakeStaff(outboundVO.getMakeStaff());
                 inboundVO.setMakeStaff(outboundVO.getMakeStaff());
                 //公司
                 //公司
                 inboundVO.setCpId(outboundVO.getCpId());
                 inboundVO.setCpId(outboundVO.getCpId());
+                // 来源Id
+                inboundVO.setFromId(outboundVO.getFromId());
+                inboundVO.setFromNo(outboundVO.getFromNo());
                 //实体转换
                 //实体转换
                 Inbound inbound = inboundConvert.convertToPo(inboundVO);
                 Inbound inbound = inboundConvert.convertToPo(inboundVO);
                 inboundMapper.insert(inbound);
                 inboundMapper.insert(inbound);
@@ -311,14 +337,18 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     //入库类型
                     //入库类型
                     inboundItemVO.setIntoType(inboundVO.getIntoType());
                     inboundItemVO.setIntoType(inboundVO.getIntoType());
                     //入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
                     //入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
+                    BigDecimal costAmount = outboundItemVO.getOutQty().multiply(outboundItemVO.getPriceOut()).setScale(2, BigDecimal.ROUND_HALF_UP);
                     inboundItemVO
                     inboundItemVO
+                            .setFromId(outboundItemVO.getFromId())
+                            .setFromItemId(outboundItemVO.getFromItemId())
                             .setPriceInto(outboundItemVO.getPriceOut())
                             .setPriceInto(outboundItemVO.getPriceOut())
                             .setIntoQty(outboundItemVO.getOutQty())
                             .setIntoQty(outboundItemVO.getOutQty())
-                            .setIntoAmt(outboundItemVO.getOutQty())
+                            .setIntoAmt(outboundItemVO.getOutAmt())
+                            .setIntoAmt(costAmount)
                             .setIntoingQty(BigDecimal.ZERO)
                             .setIntoingQty(BigDecimal.ZERO)
                             .setIntoingAmt(BigDecimal.ZERO)
                             .setIntoingAmt(BigDecimal.ZERO)
                             .setCostPrice(outboundItemVO.getPriceOut())
                             .setCostPrice(outboundItemVO.getPriceOut())
-                            .setCostAmt(outboundItemVO.getOutQty().multiply(outboundItemVO.getPriceOut()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                            .setCostAmt(costAmount)
                     ;
                     ;
                     //入库状态
                     //入库状态
                     inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
                     inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
@@ -339,6 +369,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     // 商品
                     // 商品
                     inboundItemVO.setSkuModel(outboundItemVO.getSkuModel());
                     inboundItemVO.setSkuModel(outboundItemVO.getSkuModel());
                     inboundItemVO.setSkuName(outboundItemVO.getSkuName());
                     inboundItemVO.setSkuName(outboundItemVO.getSkuName());
+                    // 来源Id
                     //实体转换
                     //实体转换
                     InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
                     InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
                     inboundItemMapper.insert(inboundItem);
                     inboundItemMapper.insert(inboundItem);
@@ -383,6 +414,14 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
         //endregion
         //endregion
 
 
         //region  总单
         //region  总单
+        //出库数量
+        BigDecimal sumIntoQty = BigDecimal.ZERO;
+        //出库金额
+        BigDecimal sumIntoPriceAmt = BigDecimal.ZERO;
+        if(orderTransmitFlag){
+            sumIntoQty = outboundVO.getItemList().stream().map(OutboundItemVO::getOutingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+            sumIntoPriceAmt = outboundVO.getItemList().stream().map(OutboundItemVO::getPriceOut).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+        }
         //获取 id/单号
         //获取 id/单号
         Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.SALEORDER.getName(), false);
         Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.SALEORDER.getName(), false);
         outboundVO.setOutId(codeMap.get("outId").toString()).
         outboundVO.setOutId(codeMap.get("outId").toString()).
@@ -400,8 +439,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
         //出库状态等于已出库 更新合计出库数量/金额 = 出库中数量/出库中金额
         //出库状态等于已出库 更新合计出库数量/金额 = 出库中数量/出库中金额
         if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())) {
         if (Constant.OutStatus.YICHUKU.getName().equals(outboundVO.getOutStatus())) {
             outboundVO
             outboundVO
-                    .setOutQty(outboundVO.getOutingQty())
-                    .setOutAmt(outboundVO.getOutingAmt())
+                    .setOutQty(orderTransmitFlag ? sumIntoQty : outboundVO.getOutingQty())
+                    .setOutAmt(orderTransmitFlag ? sumIntoQty.multiply(sumIntoPriceAmt) : outboundVO.getOutingAmt())
                     .setOutingQty(BigDecimal.ZERO)
                     .setOutingQty(BigDecimal.ZERO)
                     .setOutingAmt(BigDecimal.ZERO)
                     .setOutingAmt(BigDecimal.ZERO)
             ;
             ;
@@ -409,6 +448,9 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
             outboundVO
             outboundVO
                     .setOutQty(BigDecimal.ZERO)
                     .setOutQty(BigDecimal.ZERO)
                     .setOutAmt(BigDecimal.ZERO)
                     .setOutAmt(BigDecimal.ZERO)
+                    //用于销售订单自动创建出库单
+                    .setOutingQty(orderTransmitFlag ? sumIntoQty : outboundVO.getOutingQty())
+                    .setOutingAmt(orderTransmitFlag ? sumIntoQty.multiply(sumIntoPriceAmt) : outboundVO.getOutingAmt())
             ;
             ;
         }
         }
 
 
@@ -462,7 +504,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     ErrorCodeEnum.OUTBOUND_ITEM_NOT_EXIST.getMessage());
                     ErrorCodeEnum.OUTBOUND_ITEM_NOT_EXIST.getMessage());
         }
         }
         for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
         for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
-
+            outboundItemVO.setItemId(null );
             //region 将库存需要的参数赋值
             //region 将库存需要的参数赋值
             outboundItemVO.setInventoryType(Constant.InventoryType.OUTBOUND.getName());
             outboundItemVO.setInventoryType(Constant.InventoryType.OUTBOUND.getName());
             outboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.SALE_ORDER.getValue());
             outboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.SALE_ORDER.getValue());

+ 13 - 0
src/main/java/com/dk/mdm/service/mst/DictionaryDataService.java

@@ -1,5 +1,6 @@
 package com.dk.mdm.service.mst;
 package com.dk.mdm.service.mst;
 
 
+import com.dk.common.exception.BaseBusinessException;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.annotaiton.Pagination;
 import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.infrastructure.constant.Constant;
 import com.dk.common.infrastructure.enums.ErrorCodeEnum;
 import com.dk.common.infrastructure.enums.ErrorCodeEnum;
@@ -98,6 +99,12 @@ public class DictionaryDataService extends BaseService<DictionaryData> {
     public ResponseResultVO<?> insert(DictionaryDataVO dictionaryDataVO) {
     public ResponseResultVO<?> insert(DictionaryDataVO dictionaryDataVO) {
         //实体转换
         //实体转换
         DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO);
         DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO);
+        // 同类型名称不允许重复
+        Long count = dictionaryDataMapper.checkValueDuplicated(dictionaryData);
+        if(count > 0){
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_DATAVALUE.getMessage());
+        }
+
         Map<String, Object> map = new HashMap<>();
         Map<String, Object> map = new HashMap<>();
         map.put("dictCode", dictionaryDataVO.getDictCode());
         map.put("dictCode", dictionaryDataVO.getDictCode());
         //设置序号
         //设置序号
@@ -131,6 +138,12 @@ public class DictionaryDataService extends BaseService<DictionaryData> {
     )
     )
     public ResponseResultVO<?> update(DictionaryDataVO dictionaryDataVO) {
     public ResponseResultVO<?> update(DictionaryDataVO dictionaryDataVO) {
         DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO);
         DictionaryData dictionaryData = dictionaryDataConvert.convertToPo(dictionaryDataVO);
+        // 同类型名称不允许重复
+        Long count = dictionaryDataMapper.checkValueDuplicated(dictionaryData);
+        if(count > 0){
+            throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.ISEXISTS_DATAVALUE.getMessage());
+        }
+        // 根据Id查询当前数据
         DictionaryData dictionaryDataItem = dictionaryDataMapper.selectById(dictionaryDataVO.getDataId());
         DictionaryData dictionaryDataItem = dictionaryDataMapper.selectById(dictionaryDataVO.getDataId());
         if (dictionaryDataItem.getSysCode() != null) {
         if (dictionaryDataItem.getSysCode() != null) {
             //系统预制 无法编辑
             //系统预制 无法编辑

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

@@ -988,7 +988,7 @@ public class ReportService {
     public ResponseResultVO<Map<String, Object>> getSaleProfitGroupByStaff(Map<String, Object> param) {
     public ResponseResultVO<Map<String, Object>> getSaleProfitGroupByStaff(Map<String, Object> param) {
         Map<String, Object> res = new HashMap<>();
         Map<String, Object> res = new HashMap<>();
         res.put("profit", reportMapper.getSaleProfit(param));
         res.put("profit", reportMapper.getSaleProfit(param));
-        res.put("orgProfit", reportMapper.getSaleProfitGroupByStaff(param));
+        res.put("staffProfit", reportMapper.getSaleProfitGroupByStaff(param));
         return ResponseResultUtil.success(res);
         return ResponseResultUtil.success(res);
     }
     }
 
 
@@ -1000,7 +1000,7 @@ public class ReportService {
     public ResponseResultVO<Map<String, Object>> getSaleProfitGroupBySku(Map<String, Object> param) {
     public ResponseResultVO<Map<String, Object>> getSaleProfitGroupBySku(Map<String, Object> param) {
         Map<String, Object> res = new HashMap<>();
         Map<String, Object> res = new HashMap<>();
         res.put("profit", reportMapper.getSaleProfit(param));
         res.put("profit", reportMapper.getSaleProfit(param));
-        res.put("orgProfit", reportMapper.getSaleProfitGroupBySku(param));
+        res.put("skuProfit", reportMapper.getSaleProfitGroupBySku(param));
         return ResponseResultUtil.success(res);
         return ResponseResultUtil.success(res);
     }
     }
 }
 }

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

@@ -258,7 +258,7 @@ public class OrderService extends BaseService<Order> {
         orderVO.setOrderId(codeMap.get("outId").toString()).setOrderNo(codeMap.get("outNote").toString())
         orderVO.setOrderId(codeMap.get("outId").toString()).setOrderNo(codeMap.get("outNote").toString())
                 .setOrderType(Constant.DocumentType.ORDER.getName());
                 .setOrderType(Constant.DocumentType.ORDER.getName());
         // 转化实体
         // 转化实体
-        Order order = orderConvert.convertToPo(orderVO);
+         Order order = orderConvert.convertToPo(orderVO);
         // 订单总单保存
         // 订单总单保存
         super.insert(order);
         super.insert(order);
 
 
@@ -297,7 +297,15 @@ public class OrderService extends BaseService<Order> {
             for (OrderItemVO orderItemVO : orderVO.getItemList()) {
             for (OrderItemVO orderItemVO : orderVO.getItemList()) {
                 OrderItem orderItem = orderItemConvert.convertToPo(orderItemVO);
                 OrderItem orderItem = orderItemConvert.convertToPo(orderItemVO);
                 orderItem.setOrderId(order.getOrderId()).setCpId(order.getCpId()).setOutStatus(Constant.OutStatus.DAICHUKU.getName());
                 orderItem.setOrderId(order.getOrderId()).setCpId(order.getCpId()).setOutStatus(Constant.OutStatus.DAICHUKU.getName());
+               if( orderItem.getPriceStd()==null){
+                 orderItem.setPriceStd(BigDecimal.ZERO);
+               }
+                if( orderItem.getAmtStd()==null){
+                    orderItem.setAmtStd(BigDecimal.ZERO);
+                }
+                orderItem.setItemId(UUID.randomUUID().toString());
                 orderItemMapper.insert(orderItem);
                 orderItemMapper.insert(orderItem);
+                orderItemVO.setItemId(orderItem.getItemId());
             }
             }
         }
         }
 
 
@@ -446,14 +454,21 @@ public class OrderService extends BaseService<Order> {
                 orderItemVO.setOutingAmt(orderItemVO.getItemAmt());
                 orderItemVO.setOutingAmt(orderItemVO.getItemAmt());
                 orderItemVO.setPriceOut(orderItemVO.getPriceSale());
                 orderItemVO.setPriceOut(orderItemVO.getPriceSale());
                 orderItemVO.setFromId(orderVO.getOrderId());
                 orderItemVO.setFromId(orderVO.getOrderId());
-                orderItemVO.setFromItemId(orderItemVO.getFromItemId());
+                orderItemVO.setFromItemId(orderItemVO.getItemId());
             }
             }
             OutboundVO outboundVO = outBoundDtoConvert.convertToPo(orderVO);
             OutboundVO outboundVO = outBoundDtoConvert.convertToPo(orderVO);
             outboundVO.setOutDate(LocalDate.now());
             outboundVO.setOutDate(LocalDate.now());
             outboundVO.setOutingQty(orderVO.getSumQuantity());
             outboundVO.setOutingQty(orderVO.getSumQuantity());
-            outboundVO.setOutingAmt(orderVO.getSumAmount());
+            outboundVO.setOutingAmt(orderVO.getFactAmt());
             outboundVO.setFlgAutoHandle(orderVO.getFlgAutoHandle());
             outboundVO.setFlgAutoHandle(orderVO.getFlgAutoHandle());
             outboundVO.setFlgHandleSetting(orderVO.getFlgHandleSetting());
             outboundVO.setFlgHandleSetting(orderVO.getFlgHandleSetting());
+            outboundVO.setFromId(order.getOrderId());
+            outboundVO.setFromNo(order.getOrderNo());
+            outboundVO.setOutDate(orderVO.getDeliveryDate());
+            outboundVO.setFactAmt(orderVO.getFactAmt());
+            outboundVO.setDiscount(orderVO.getDiscount());
+            outboundVO.setDiscAmt(orderVO.getDiscAmt());
+            outboundVO.setSumAmount(orderVO.getSumAmount());
             outboundSaleOrderService.inventoryOUtBond(outboundVO);
             outboundSaleOrderService.inventoryOUtBond(outboundVO);
         }
         }