Przeglądaj źródła

合同,报价单添加真归属公司字段,销售合同添加归属类型字段

yzc 1 rok temu
rodzic
commit
3ffe9789c1

+ 20 - 21
hx-form/src/main/java/com/fjhx/form/service/impl/StatisticsServiceImpl.java

@@ -12,7 +12,6 @@ import com.fjhx.form.service.StatisticsService;
 import com.fjhx.mes.entity.production.po.ProductionOrder;
 import com.fjhx.mes.service.production.ProduceOrderService;
 import com.fjhx.purchase.service.subscribe.SubscribeDetailService;
-import com.fjhx.sale.entity.contract.po.Contract;
 import com.fjhx.sale.entity.contract.vo.ContractVo;
 import com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo;
 import com.fjhx.sale.entity.sale.po.SaleQuotation;
@@ -23,15 +22,15 @@ import com.fjhx.wms.entity.stock.dto.StockSelectDto;
 import com.fjhx.wms.entity.stock.dto.StockWaitDetailsSelectDto;
 import com.fjhx.wms.service.stock.StockService;
 import com.fjhx.wms.service.stock.StockWaitDetailsService;
-import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
-import com.ruoyi.system.utils.UserUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 @Service
 public class StatisticsServiceImpl implements StatisticsService {
@@ -172,21 +171,14 @@ public class StatisticsServiceImpl implements StatisticsService {
     public List<ContractVo> getRecentContractShipmentList() {
         IWrapper<Object> wrapper = IWrapper.getWrapper();
 
-        //不是业务员看所有
-
-
-        SysUser sysUser = UserUtil.getUserInfo();
-        if (StringUtils.isNotEmpty(sysUser.getUserCode())) {
-            //是业务员
-            List<Long> authIdList = customerService.getAuthIdList();
-            if (authIdList.size() == 0) {
-                return new ArrayList<>();
-            }
-            wrapper.in("t1", Contract::getBuyCorporationId, authIdList);
+        //权限过滤:近期出货合同-子公司看自己的,总公司看全部
+        Long companyId = SecurityUtils.getCompanyId();
+        if (!Objects.equals(companyId, 100L)) {
+            wrapper.eq("c.company_id", companyId);
         }
-        wrapper.ge("DATEDIFF(t1.shipment_time,NOW())", 0);
-        wrapper.le("DATEDIFF(t1.shipment_time,NOW())", 7);
-        wrapper.apply("t1.sumPackQuantity<t1.quantity");
+        wrapper.eq("c.status", 30);
+        wrapper.ge("DATEDIFF(c.delivery_time,NOW())", 0);
+        wrapper.le("DATEDIFF(c.delivery_time,NOW())", 7);
         List<ContractVo> contractSaitShipmentList = statisticsMapper.getRecentContractShipmentList(wrapper);
         return contractSaitShipmentList;
     }
@@ -194,8 +186,15 @@ public class StatisticsServiceImpl implements StatisticsService {
     @Override
     public List<EhsdPurchaseVo> getRecentPurchaseArrivalList() {
         IWrapper<Object> wrapper = IWrapper.getWrapper();
-        wrapper.ge("DATEDIFF(pa.arrival_time,NOW())", 0);
-        wrapper.le("DATEDIFF(pa.arrival_time,NOW())", 7);
+
+        //权限过滤:近期出货合同-子公司看自己的,总公司看全部
+        Long companyId = SecurityUtils.getCompanyId();
+        if (!Objects.equals(companyId, 100L)) {
+            wrapper.eq("p.company_id", companyId);
+        }
+
+        wrapper.ge("DATEDIFF(p.delivery_time,NOW())", 0);
+        wrapper.le("DATEDIFF(p.delivery_time,NOW())", 7);
         wrapper.eq("p.status", 30);
         List<EhsdPurchaseVo> contractSaitShipmentList = statisticsMapper.getRecentPurchaseArrivalList(wrapper);
         return contractSaitShipmentList;

+ 7 - 16
hx-form/src/main/resources/mapper/StatisticsMapper.xml

@@ -3,30 +3,21 @@
 <mapper namespace="com.fjhx.form.mapper.StatisticsMapper">
 
     <select id="getRecentContractShipmentList" resultType="com.fjhx.sale.entity.contract.vo.ContractVo">
-        SELECT *
-        FROM (SELECT c.id,
-                     c.code,
-                     c.buy_corporation_id,
-                     cs.shipment_time,
-                     cs.quantity,
-                     IFNULL(SUM(pd.pack_quantity * pdp.quantity), 0) AS sumPackQuantity
-              FROM contract c
-                       JOIN contract_shipment cs ON cs.contract_id = c.id
-                       LEFT JOIN pack_detail_product pdp ON pdp.contract_id = c.id
-                  AND pdp.product_id = cs.product_id
-                       LEFT JOIN pack_detail pd ON pdp.pack_detail_id = pd.id
-              WHERE c.`status` = 30
-              GROUP BY c.id) t1
+        SELECT c.id,
+               c.code,
+               c.buy_corporation_id,
+               c.delivery_time,
+               c.create_time
+        FROM contract c
             ${ew.customSqlSegment}
     </select>
     <select id="getRecentPurchaseArrivalList" resultType="com.fjhx.sale.entity.purchase.vo.EhsdPurchaseVo">
         SELECT p.id,
                p.`code`,
-               pa.arrival_time,
                p.flow_id,
+               p.delivery_time,
                p.data_resource
         FROM ehsd_purchase p
-                 JOIN ehsd_purchase_arrival pa ON pa.purchase_id = p.id
             ${ew.customSqlSegment}
     </select>
 </mapper>

+ 1 - 0
hx-mes/src/main/java/com/fjhx/mes/service/production/impl/ProduceOrderServiceImpl.java

@@ -523,6 +523,7 @@ public class ProduceOrderServiceImpl extends ServiceImpl<ProduceOrderMapper, Pro
     @Override
     public ProductionOrderVo detail(Long id) {
         ProductionOrder productionOrder = this.getById(id);
+        Assert.notEmpty(productionOrder, "查询不到生产订单信息");
         ProductionOrderVo productionOrderVo = BeanUtil.copyProperties(productionOrder, ProductionOrderVo.class);
 
         List<EhsdPurchaseProductVo> ehsdPurchaseProductVos = ehsdPurchaseProductMapper.getList(IWrapper.<EhsdPurchaseProduct>getWrapper()

+ 10 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/dto/ContractSelectDto.java

@@ -114,4 +114,14 @@ public class ContractSelectDto extends BaseSelectDto {
      * 订单类型 0销售合同 1样品单
      */
     private Integer type;
+
+    /**
+     * 订单归属
+     */
+    private Integer belongType;
+
+    /**
+     * 归属公司id
+     */
+    private Long ofCompanyId;
 }

+ 9 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/po/Contract.java

@@ -476,5 +476,14 @@ public class Contract extends BasePo {
      */
     private Long merchUserId;
 
+    /**
+     * 订单归属
+     */
+    private Integer belongType;
+
+    /**
+     * 归属公司id
+     */
+    private Long ofCompanyId;
 
 }

+ 10 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/dept/vo/DeptPerfVo.java

@@ -24,4 +24,14 @@ public class DeptPerfVo extends DeptPerf {
      */
     private String groupName;
 
+    /**
+     * 公司名称
+     */
+    private String companyName;
+
+    /**
+     * 归属公司id
+     */
+    private Long companyId;
+
 }

+ 5 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/ext/po/ExtQuotation.java

@@ -121,4 +121,9 @@ public class ExtQuotation extends BasePo {
      */
     private Date lastFollowTime;
 
+    /**
+     * 归属公司id
+     */
+    private Long ofCompanyId;
+
 }

+ 4 - 108
hx-sale/src/main/java/com/fjhx/sale/entity/sale/po/SaleQuotation.java

@@ -116,112 +116,8 @@ public class SaleQuotation extends BasePo {
      */
     private String backRemark;
 
-
-//
-//
-//    /**
-//     * 合同模版ID
-//     */
-//    private Long contractTemplateId;
-//
-//    /**
-//     * 卖方公司ID
-//     */
-//    private Long sellCorporationId;
-//
-//
-//
-//    /**
-//     * 卖方联系人名称
-//     */
-//    private String sellContactName;
-//
-//    /**
-//     * 卖方联系人电话
-//     */
-//    private String sellContactNumber;
-//
-//    /**
-//     * 卖方国家表id
-//     */
-//    private String sellCountryId;
-//
-//    /**
-//     * 卖方省份id
-//     */
-//    private String sellProvinceId;
-//
-//    /**
-//     * 卖方城市id
-//     */
-//    private String sellCityId;
-//
-//    /**
-//     * 卖方国家表名称
-//     */
-//    private String sellCountryName;
-//
-//    /**
-//     * 卖方省份名称
-//     */
-//    private String sellProvinceName;
-//
-//    /**
-//     * 卖方城市名称
-//     */
-//    private String sellCityName;
-//
-//    /**
-//     * 卖方详细地址
-//     */
-//    private String sellAddress;
-//
-//
-//
-//    /**
-//     * 币种(字典account_currency)
-//     */
-//    private String currency;
-//
-//
-//
-//    /**
-//     * 付款方式(字典funds_payment_method(多余的业务字段)
-//     */
-//    private String paymentMethod;
-//
-//    /**
-//     * 贸易方式(字典trade_methods)
-//     */
-//    private String tradeMethods;
-//
-//    /**
-//     * 预付比例
-//     */
-//    private String advanceRatio;
-//
-//    /**
-//     * 运输方式(字典  shipping_method)
-//     */
-//    private String transportMethod;
-//
-//    /**
-//     * 运输备注
-//     */
-//    private String transportRemark;
-//
-//    /**
-//     * 有效期
-//     */
-//    private Integer effective;
-//
-//    /**
-//     * 质保期
-//     */
-//    private Integer warranty;
-//
-//    /**
-//     * 付款条件
-//     */
-//    private String remark;
+    /**
+     * 归属公司id
+     */
+    private Long ofCompanyId;
 }

+ 3 - 0
hx-sale/src/main/java/com/fjhx/sale/flow/ContractFlow.java

@@ -121,6 +121,9 @@ public class ContractFlow extends FlowDelegate {
         //销售部门id
         contract.setDeptId(SecurityUtils.getDeptId());
 
+        //赋值归属公司
+        contract.setOfCompanyId(SecurityUtils.getCompanyId());
+
         // 赋值城市省份信息
         CustomizeAreaUtil.setAreaId(contract);
         SysUser loginUser = SecurityUtils.getLoginUser().getUser();

+ 16 - 6
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -328,13 +328,16 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
      */
     private void setContractParam(ContractSelectDto dto, IWrapper<Contract> wrapper) {
         //权限过滤:销售合同-子公司看自己的,总公司看全部
-        Long companyId = SecurityUtils.getCompanyId();
-        if (!Objects.equals(companyId, 100L)) {
-            wrapper.eq("t1", Contract::getCompanyId, companyId);
+        Long ofCompanyId = SecurityUtils.getCompanyId();
+        if (!Objects.equals(ofCompanyId, 100L)) {
+            wrapper.eq("t1", Contract::getOfCompanyId, ofCompanyId);
         } else {
-            wrapper.eq("t1", Contract::getCompanyId, dto.getCompanyId());
+            wrapper.eq("t1", Contract::getOfCompanyId, dto.getOfCompanyId());
         }
 
+        //生产公司过滤
+        wrapper.eq("t1", Contract::getCompanyId, dto.getCompanyId());
+
         wrapper.orderByDesc("t1", Contract::getCreateTime);
         if (StringUtils.isNotEmpty(dto.getStatus())) {
             wrapper.eq("t1", Contract::getStatus, dto.getStatus());
@@ -411,8 +414,15 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
         wrapper.ge("t1", Contract::getDeliveryTime, dto.getDeliveryTimeSta());
         wrapper.le("t1", Contract::getDeliveryTime, dto.getDeliveryTimeEnd());
 
-        //订单类型过滤
-        wrapper.eq("t1", Contract::getType, dto.getType());
+//        //订单类型过滤
+//        wrapper.eq("t1", Contract::getType, dto.getType());
+
+        //合同类型过滤
+        wrapper.eq("t1", Contract::getContractType, dto.getContractType());
+
+        //订单归属过滤(1归属工厂、2归属业务)
+        wrapper.eq("t1", Contract::getBelongType, dto.getBelongType());
+
     }
 
     /**

+ 2 - 0
hx-sale/src/main/java/com/fjhx/sale/service/ext/impl/ExtQuotationServiceImpl.java

@@ -37,6 +37,7 @@ import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import com.ruoyi.system.service.ISysDeptService;
 import com.ruoyi.system.service.ISysUserService;
@@ -307,6 +308,7 @@ public class ExtQuotationServiceImpl extends ServiceImpl<ExtQuotationMapper, Ext
      * 添加修改公共方法
      */
     private void saveOrEdit(ExtQuotationDto saleQuotationDto) {
+        saleQuotationDto.setOfCompanyId(SecurityUtils.getCompanyId());
         this.saveOrUpdate(saleQuotationDto);
 
         List<ExtQuotationProductDto> quotationProductList = saleQuotationDto.getQuotationProductList();

+ 2 - 1
hx-sale/src/main/java/com/fjhx/sale/service/sale/impl/SaleQuotationServiceImpl.java

@@ -117,7 +117,7 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
 
         //权限过滤:报价评估自己看自己
         if (Objects.equals(dto.getIsEstimate(), 1)) {
-            wrapper.eq("sq", SaleQuotation::getCompanyId, SecurityUtils.getCompanyId());
+            wrapper.eq("sq", SaleQuotation::getOfCompanyId, SecurityUtils.getCompanyId());
             wrapper.ne("sq", SaleQuotation::getStatus, FlowStatusEnum1.DRAFT.getKey());
         }
 
@@ -292,6 +292,7 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
      * 添加修改公共方法
      */
     private void saveOrEdit(SaleQuotationDto saleQuotationDto) {
+        saleQuotationDto.setOfCompanyId(SecurityUtils.getCompanyId());
         this.saveOrUpdate(saleQuotationDto);
 
         List<QuotationProductDto> quotationProductList = saleQuotationDto.getQuotationProductList();

+ 3 - 0
hx-sale/src/main/resources/mapper/dept/DeptPerfMapper.xml

@@ -3,6 +3,8 @@
 <mapper namespace="com.fjhx.sale.mapper.dept.DeptPerfMapper">
     <select id="getList" resultType="com.fjhx.sale.entity.dept.vo.DeptPerfVo">
         SELECT dep.id,
+               co.dept_id                      as companyId,
+               co.dept_name                    as companyName,
                de.dept_id,
                de.dept_name,
                gr.dept_id                      AS groupId,
@@ -22,6 +24,7 @@
                dep.december
         FROM sys_dept gr
                  LEFT JOIN sys_dept de ON gr.parent_id = de.dept_id
+                 left join sys_dept co on de.parent_id = co.dept_id
                  LEFT JOIN dept_perf dep ON dep.group_id = gr.dept_id AND dep.years = #{dto.years}
         WHERE gr.type != 0
               AND FIND_IN_SET(100,gr.ancestors)