zhangyuewww 3 years ago
parent
commit
3e5372e79e

+ 1 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/constant/StatusEnum.java

@@ -84,6 +84,7 @@ public enum StatusEnum {
 
     // 采购入库统计,采购平仓统计
     PUR_REVIEWED("1", "待审核", ""),
+    SETTLED("2", "已结算", "settled"),
     PUR_PAY("3", "部分付款", ""),
     PUR_PAYaLL("5", "全部付款", ""),
     PUR_RETURN("7", "已驳回", ""),

+ 4 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/SourceRelationInfo.java

@@ -8,10 +8,12 @@ import com.baomidou.mybatisplus.annotations.TableField;
 import com.baomidou.mybatisplus.annotations.TableId;
 import com.baomidou.mybatisplus.annotations.TableName;
 import com.baomidou.mybatisplus.enums.IdType;
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.yh.saas.common.support.entity.BaseModel;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
 
 /**
  * <p>
@@ -77,6 +79,8 @@ public class SourceRelationInfo extends BaseModel<SourceRelationInfo> {
     /**
      * 出单时间
      */
+    @JsonFormat(pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
     private Date issuingTime;
     /**
      * 车牌号

+ 15 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/entity/WarehouseBaseInfo.java

@@ -243,10 +243,25 @@ public class WarehouseBaseInfo extends BaseModel<WarehouseBaseInfo> {
      */
     @TableField(exist = false)
     private Double saleWeight;
+    /**
+     * 成本
+     */
+    @TableField(exist = false)
+    private Double cost;
     @TableField(exist = false)
     private List<WarehouseBaseInfo> chartList;
     @TableField(exist = false)
     private List<WarehouseBaseInfo> formList;
+    /**
+     * 图表类型
+     */
+    @TableField(exist = false)
+    private String type;
+    /**
+     * 图表值
+     */
+    @TableField(exist = false)
+    private Double num;
 
 
 

+ 7 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/mapper/WarehouseBaseInfoMapper.java

@@ -101,4 +101,11 @@ public interface WarehouseBaseInfoMapper extends BaseMapper<WarehouseBaseInfo> {
      * @return
      */
     List<WarehouseBaseInfo> getWarehouseChartByCondition(Map<String, Object> pageView);
+    /**
+     * 库点利润表
+     *
+     * @param pageView
+     * @return
+     */
+    List<WarehouseBaseInfo> getWarehouseFormByCondition(Map<String, Object> pageView);
 }

+ 6 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/ExpenseInfoServiceImpl.java

@@ -352,6 +352,8 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
         }
         //编辑分配
         else if ("3".equals(expenseInfo.getFlag())){
+            expenseInfo.setDistributionStatusFlag(StatusEnum.TO_BE_CONFIRMED.getFlag());
+            expenseInfo.setDistributionStatus(StatusEnum.TO_BE_CONFIRMED.getName());
             List<ExpenseAllocationInfo> expenseAllocationInfoList = expenseInfo.getExpenseAllocationInfoList();
             if (!CollectionUtils.isEmpty(expenseAllocationInfoList)) {
                 for (ExpenseAllocationInfo expenseAllocationInfo : expenseAllocationInfoList) {
@@ -471,6 +473,9 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
      */
     @Override
     public void deleteAllocationInfo(String id) {
+        ExpenseInfo expenseInfo=this.selectById(id);
+        expenseInfo.setDistributionStatusFlag("");
+        expenseInfo.setDistributionStatus("");
         List<ExpenseAllocationInfo> expenseAllocationInfos=expenseAllocationInfoService.selectList(new EntityWrapper<ExpenseAllocationInfo>()
                 .eq("info_id",id)
                 .ne("status","已通过"));
@@ -479,6 +484,7 @@ public class ExpenseInfoServiceImpl extends ServiceImpl<ExpenseInfoMapper, Expen
                 expenseAllocationInfoService.deleteInfo(expenseAllocationInfo.getId());
             }
         }
+        this.updateById(expenseInfo);
     }
 
     @Override

+ 2 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/java/com/yh/saas/plugin/yiliangyiyun/service/impl/WarehouseBaseInfoServiceImpl.java

@@ -5556,7 +5556,9 @@ public class WarehouseBaseInfoServiceImpl extends ServiceImpl<WarehouseBaseInfoM
         pageView.put("startDate", warehouseBaseInfo.getStartDate());
         pageView.put("endDate", warehouseBaseInfo.getEndDate());
         List<WarehouseBaseInfo> dataList = baseMapper.getWarehouseChartByCondition(pageView);
+        List<WarehouseBaseInfo> dataList1 = baseMapper.getWarehouseFormByCondition(pageView);
         warehouseBaseInfo1.setChartList(dataList);
+        warehouseBaseInfo1.setFormList(dataList1);
 
         return warehouseBaseInfo1;
     }

+ 198 - 4
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ContractManagementInfoMapper.xml

@@ -315,15 +315,126 @@
         m.buyer,
         m.signing_date as signingDate,
         m.status,
-        ci.inventory as inventory,
+        SUM(wo.surplus_weight) as surplus,
+        IFNULL(SUM( IFNULL( sri.proportion, 1 ) * IFNULL( ssrr.amount_ing_receivable, 0 ) ) + SUM( exi.amount_money )- SUM( exi2.amount_money ),0) AS profit,
         m.approve_status as approveStatus,
         m.agreement_type as agreementType
         FROM contract_management_info m
-        LEFT JOIN contract_cost_info c on m.id = c.contract_id
-        LEFT JOIN contract_inventory_distribution ci on m.id = ci.contract_id
+        LEFT JOIN warehousing_order wo on wo.contract_no = m.contract_no and wo.comp_id=m.comp_id and wo.delete_flag = '0'
+        LEFT JOIN expense_info exi ON exi.contract_id = m.id
+        AND exi.expenses_type = '1'
+        AND exi.expenses_purpose = '1'
+        AND exi.delete_flag = '0'
+        LEFT JOIN expense_info exi2 ON exi2.contract_id = m.id
+        AND exi2.expenses_type = '2'
+        AND exi2.expenses_purpose = '1'
+        AND exi2.delete_flag = '0'
+        LEFT JOIN warehousing_order war ON war.contract_no = m.contract_no
+        AND war.comp_id = m.comp_id
+        AND war.delete_flag = '0'
+        LEFT JOIN source_relation_info sri ON sri.source_id = war.id
+        AND sri.delete_flag = '0'
+        LEFT JOIN in_out_warehouse_task iowt ON iowt.id = sri.task_id
+        AND iowt.in_out_flag = 1
+        AND iowt.in_out_type_key = 1
+        AND iowt.delete_flag = '0'
+        LEFT JOIN warehouse_in_out_info wioi ON wioi.in_out_task_no = iowt.in_out_task_no
+        and wioi.car_no = sri.car_no
+        AND wioi.delete_flag = 0
+        AND wioi.status_flag = 3
+        LEFT JOIN stock_sale_receipt_report ssrr ON ssrr.contract_no = iowt.contract_no
+        AND ssrr.warehouse_record_id = wioi.id
+        and ssrr.delete_flag = 0
+        WHERE
+        m.comp_id = #{compId}
+        AND m.delete_flag = '0'
+        and m.contract_type='2'
+        <if test="searchTypeCon != null and searchTypeCon != ''">
+            <!--执行中-->
+            <if test="searchTypeCon == 1">
+                AND (m.status_flag == '1' or approve_status='待决策人审核')
+            </if>
+            <!--已完成-->
+            <if test="searchTypeCon == 2">
+                AND m.status_flag = '3'
+            </if>
+            <!--发运结束-->
+            <if test="searchTypeCon == 3">
+                AND m.status_flag = '2'
+            </if>
+            <!--待执行-->
+            <if test="searchTypeCon == 4">
+                AND m.status_flag = '0'
+            </if>
+        </if>
+        <if test="searchContractType != null and searchContractType != ''">
+            <!--销售合同-->
+            <if test="searchContractType == 1">
+                AND m.contract_type = '1'
+            </if>
+            <!--采购合同-->
+            <if test="searchContractType == 2">
+                AND m.contract_type = '2'
+            </if>
+            <!--代收合同-->
+            <if test="searchContractType == 3">
+                AND m.contract_type = '3'
+                AND m.agreement_type = '代收合同'
+            </if>
+            <!--代储合同-->
+            <if test="searchContractType == 4">
+                AND m.contract_type = '1'
+                AND m.agreement_type = '代储合同'
+            </if>
+        </if>
+        <if test="startDate != null">
+            AND (DATE_FORMAT(m.signing_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(m.signing_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(m.contract_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower( m.buyer) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower( m.seller) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        GROUP BY m.contract_no
+        UNION ALL
+        SELECT
+        m.id,
+        m.comp_id as compId,
+        m.contract_no as contractNo,
+        m.contract_type as contractType,
+        m.seller,
+        m.buyer,
+        m.signing_date as signingDate,
+        m.status,
+        '' as surplus,
+        IFNULL(SUM( exi.amount_money )- SUM(ssrr.settlement_weight* wo.avg_cost)- SUM( exi2.unallocated_amount ) ,0)AS profit,
+        m.approve_status as approveStatus,
+        m.agreement_type as agreementType
+        FROM contract_management_info m
+        LEFT JOIN expense_info exi ON exi.contract_id = m.id
+        AND exi.expenses_type = '1'
+        AND exi.expenses_purpose = '1'
+        AND exi.delete_flag = '0'
+        LEFT JOIN expense_info exi2 ON exi2.contract_id = m.id
+        AND exi2.expenses_type = '2'
+        AND exi2.expenses_purpose = '1'
+        AND exi2.delete_flag = '0'
+        LEFT JOIN stock_sale_receipt_report ssrr ON ssrr.contract_no = m.contract_no
+        and ssrr.delete_flag = 0
+        LEFT JOIN warehouse_in_out_info wioi ON wioi.id = ssrr.warehouse_record_id
+        AND wioi.delete_flag = '0'
+        LEFT JOIN in_out_warehouse_task iowt ON iowt.in_out_task_no=wioi.in_out_task_no and iowt.delete_flag='0'
+        LEFT JOIN source_relation_info sri on sri.task_id=iowt.id and sri.delete_flag='0'
+        LEFT JOIN warehousing_order wo on wo.id=sri.source_id and wo.delete_flag='0'
         WHERE
         m.comp_id = #{compId}
         AND m.delete_flag = '0'
+        and m.contract_type='1'
         <if test="searchTypeCon != null and searchTypeCon != ''">
             <!--执行中-->
             <if test="searchTypeCon == 1">
@@ -353,7 +464,88 @@
             </if>
             <!--代收合同-->
             <if test="searchContractType == 3">
+                AND m.contract_type = '3'
+                AND m.agreement_type = '代收合同'
+            </if>
+            <!--代储合同-->
+            <if test="searchContractType == 4">
+                AND m.contract_type = '1'
+                AND m.agreement_type = '代储合同'
+            </if>
+        </if>
+        <if test="startDate != null">
+            AND (DATE_FORMAT(m.signing_date,"%Y%m%d") &gt;=
+            DATE_FORMAT(#{startDate},"%Y%m%d"))
+        </if>
+        <if test="endDate != null">
+            AND (DATE_FORMAT(m.signing_date,"%Y%m%d") &lt;=
+            DATE_FORMAT(#{endDate},"%Y%m%d"))
+        </if>
+        <if test="searchKeyWord != null and searchKeyWord != ''">
+            AND (lower(m.contract_no) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower( m.buyer) like lower(CONCAT('%',#{searchKeyWord},'%'))
+            OR lower( m.seller) like lower(CONCAT('%',#{searchKeyWord},'%')))
+        </if>
+        GROUP BY m.contract_no
+        UNION ALL
+        SELECT
+        m.id,
+        m.comp_id as compId,
+        m.contract_no as contractNo,
+        m.contract_type as contractType,
+        m.seller,
+        m.buyer,
+        m.signing_date as signingDate,
+        m.status,
+        SUM(wo.surplus_weight) as surplus,
+        SUM( exi.amount_money )- SUM( exi2.unallocated_amount ) AS profit,
+        m.approve_status as approveStatus,
+        m.agreement_type as agreementType
+        FROM contract_management_info m
+        LEFT JOIN warehousing_order wo on wo.contract_no = m.contract_no and wo.comp_id=m.comp_id and wo.delete_flag = '0'
+        LEFT JOIN expense_info exi ON exi.contract_id =  m.id
+        AND exi.expenses_type = '1'
+        AND exi.expenses_purpose = '1'
+        AND exi.delete_flag = '0'
+        LEFT JOIN expense_info exi2 ON exi2.contract_id =  m.id
+        AND exi2.expenses_type = '2'
+        AND exi2.expenses_purpose = '1'
+        AND exi2.delete_flag = '0'
+        WHERE
+        m.comp_id = #{compId}
+        AND m.delete_flag = '0'
+        and m.agreement_type!='销售合同'
+        and m.agreement_type!='采购合同'
+        <if test="searchTypeCon != null and searchTypeCon != ''">
+            <!--执行中-->
+            <if test="searchTypeCon == 1">
+                AND (m.status_flag == '1' or approve_status='待决策人审核')
+            </if>
+            <!--已完成-->
+            <if test="searchTypeCon == 2">
+                AND m.status_flag = '3'
+            </if>
+            <!--发运结束-->
+            <if test="searchTypeCon == 3">
+                AND m.status_flag = '2'
+            </if>
+            <!--待执行-->
+            <if test="searchTypeCon == 4">
+                AND m.status_flag = '0'
+            </if>
+        </if>
+        <if test="searchContractType != null and searchContractType != ''">
+            <!--销售合同-->
+            <if test="searchContractType == 1">
+                AND m.contract_type = '1'
+            </if>
+            <!--采购合同-->
+            <if test="searchContractType == 2">
                 AND m.contract_type = '2'
+            </if>
+            <!--代收合同-->
+            <if test="searchContractType == 3">
+                AND m.contract_type = '3'
                 AND m.agreement_type = '代收合同'
             </if>
             <!--代储合同-->
@@ -375,7 +567,9 @@
             OR lower( m.buyer) like lower(CONCAT('%',#{searchKeyWord},'%'))
             OR lower( m.seller) like lower(CONCAT('%',#{searchKeyWord},'%')))
         </if>
-        ORDER BY m.signing_date 
+        GROUP BY m.contract_no
+        ORDER BY
+        signingDate desc
         <if test="currentPage != null and currentPage != ''">
             LIMIT ${startRecord}, ${pageSize}
         </if>

+ 1 - 0
winsea-haixin-plugin-yiliangyiyun/src/main/resources/mapper/ExpenseInfoMapper.xml

@@ -44,6 +44,7 @@
         expenses_type as expensesType,
         purpose,
         expense_name as expenseName,
+        cost_type as costType,
         expenses_purpose as expensesPurpose,
         amount_money as amountMoney,
         unallocated_amount as unallocatedAmount,