Browse Source

同步个贷,资产产品出入库状态和财务预警页面调整

wucl 6 tháng trước cách đây
mục cha
commit
d93fce970d

+ 14 - 0
biz-base/src/main/java/com/dayou/controller/DyoaController.java

@@ -96,4 +96,18 @@ public class DyoaController {
         Boolean ret = dyoaHistoryService.updateCommissionDeclare();
         return RestResponse.data(ret);
     }
+
+    @IgnoreAuth
+    @GetMapping("/update/personalProduction")
+    public RestResponse<Boolean> updatePersonalProduction(){
+        Boolean ret = dyoaHistoryService.updatePersonalProduction();
+        return RestResponse.data(ret);
+    }
+
+    @IgnoreAuth
+    @GetMapping("/update/assetsProduction")
+    public RestResponse<Boolean> updateAssetsProduction(){
+        Boolean ret = dyoaHistoryService.updateAssetsProduction();
+        return RestResponse.data(ret);
+    }
 }

+ 9 - 0
dao/src/main/java/com/dayou/mapper/DyoaRecordMapper.java

@@ -1,5 +1,6 @@
 package com.dayou.mapper;
 
+import com.dayou.dto.history.HisPersonalProduction;
 import com.dayou.entity.DyoaRecord;
 import com.dayou.dao.CustomBaseMapper;
 import com.dayou.entity.OrderFund;
@@ -34,4 +35,12 @@ public interface DyoaRecordMapper extends CustomBaseMapper<DyoaRecord> {
 
 
     Long getMbsIdByDyOAId(@Param("id") String id);
+
+    Long getMbsIdByDyOAIdForAssets(@Param("id") String id);
+
+    List<HisPersonalProduction> findPersonalProduction();
+
+    List<HisPersonalProduction> findAssetsProduction();
+
+    Long getPersonalTargetId(@Param("id")String id);
 }

+ 20 - 0
dao/src/main/resources/mapper/DyoaRecordMapper.xml

@@ -69,4 +69,24 @@
         select mbs_id from dyoa_record where dyoa_id = #{id} and  mbs_type = 'MAJOR_ORDER'
     </select>
 
+    <select id="getMbsIdByDyOAIdForAssets" parameterType="java.lang.String" resultType="java.lang.Long">
+        select mbs_id from dyoa_record where dyoa_id = #{id} and  mbs_type = 'ASSETS_ORDER'
+    </select>
+
+    <select id="findPersonalProduction" resultType="com.dayou.dto.history.HisPersonalProduction">
+        select id,bgInRepoTime,bgOutRepoTime from dy_order_loan
+        where  masterName IS NOT NULL
+          and deleted = 0
+    </select>
+
+    <select id="getPersonalTargetId" parameterType="java.lang.String" resultType="java.lang.Long">
+        select id from  personal_target where personal_id = (select mbs_id from dyoa_record where dyoa_id = #{id})
+    </select>
+
+    <select id="findAssetsProduction" resultType="com.dayou.dto.history.HisPersonalProduction">
+        select id,bgInTime as bgInRepoTime,bgOutTime as bgOutRepoTime  from dy_assets
+        where
+            deleted = 0
+    </select>
+
 </mapper>

+ 14 - 12
dao/src/main/resources/mapper/FinanceRealFundMapper.xml

@@ -267,6 +267,7 @@
         DATEDIFF(
         CURDATE(),
         DATE( mp.repertory_out_time )) AS overdueDay,
+        pf.production,
         m.allot_type,
         m.order_id,
         m.business_object_type,
@@ -277,15 +278,16 @@
         pf.production_should_amount as shouldAmount,
         mp.*
         FROM
-        ( SELECT business_id, production_no, production_should_amount, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS'
+        ( SELECT business_id, production_no,
+        ( CASE production_type WHEN 'STATEMENT' THEN '意见书' WHEN 'REPORT' THEN '报告' WHEN 'LETTER' THEN '复评函' ELSE '' END ) production
+        , production_should_amount, real_amount FROM production_fund WHERE business_type = 'MAJOR_BUSINESS'
         AND deleted = 0 and production_should_amount is not null and production_should_amount!=0  and real_amount is null)  pf
-        left join
+        inner join
         (
         SELECT
         id,
         major_id,
         report_no,
-        ( CASE production WHEN 'STATEMENT' THEN '意见书' WHEN 'REPORT' THEN '报告' WHEN 'LETTER' THEN '复评函' ELSE '' END ) production,
         NAME,
         evaluate_amount,
         repertory_out_time,
@@ -326,7 +328,7 @@
                 </foreach>
             </if>
         </where>
-        order by overdueDay desc
+        order by overdueDay ASC
     </sql>
     <select id="overdueMajor" parameterType="com.dayou.vo.MajorProdOverdueVO" resultType="com.dayou.vo.MajorProdOverdueVO">
         <include refid="majorOverdueSql" />
@@ -1112,9 +1114,9 @@
         WHERE
         deleted = 0
         ) p
-        LEFT JOIN personal_target pt ON pt.personal_id = p.id
-        LEFT JOIN ( SELECT business_id, should_amount, real_amount FROM order_fund WHERE business_type = 'PERSONAL_BUSINESS' AND deleted = 0 AND real_amount IS NULL ) ofu ON ofu.business_id = p.id
-        LEFT JOIN ( SELECT target_id,( repertory_out_time ) rot FROM personal_production WHERE repertory_out_time IS NOT NULL GROUP BY target_id ) pp ON pp.target_id = pt.id
+        inner JOIN personal_target pt ON pt.personal_id = p.id
+        inner JOIN ( SELECT business_id, should_amount, real_amount FROM order_fund WHERE business_type = 'PERSONAL_BUSINESS' AND deleted = 0 AND real_amount IS NULL ) ofu ON ofu.business_id = p.id
+        inner JOIN ( SELECT target_id,( repertory_out_time ) rot FROM personal_production WHERE repertory_out_time IS NOT NULL GROUP BY target_id ) pp ON pp.target_id = pt.id
         LEFT JOIN customer_company cc1 ON cc1.id = p.clientele_id
         LEFT JOIN customer_company cc2 ON cc2.id = p.clientele_sub_id
         LEFT JOIN customer_linkman cl1 ON cl1.id = p.clientele_contact_id
@@ -1130,7 +1132,7 @@
                 AND DATEDIFF(CURDATE(),DATE( pp.rot )) &lt;= #{overdueVO.overdueMax}
             </if>
             <if test="overdueVO!=null and overdueVO.orderId!=null and overdueVO.orderId!=''">
-                and m.order_id = #{overdueVO.orderId}
+                and p.order_id = #{overdueVO.orderId}
             </if>
             <if test="overdueVO!=null and overdueVO.userIds!=null and overdueVO.userIds.size!=0">
                 and p.client_manager_id in
@@ -1140,7 +1142,7 @@
             </if>
         </where>
         ORDER BY
-        overdueDay DESC
+        overdueDay ASC
     </sql>
     <select id="overduePersonal" parameterType="com.dayou.vo.PersonalOverdueVO" resultType="com.dayou.vo.PersonalOverdueVO">
        <include refid="personalOverdueSql" />
@@ -1673,6 +1675,7 @@
         pf.production_should_amount,
         `of`.should_amount,
         pf.standard_amount,
+        a.name as projectName,
         ap.*
         FROM
         (
@@ -1681,7 +1684,6 @@
         business_id,
         production_no,
         ( CASE production_type WHEN 'STATEMENT' THEN '意见书' WHEN 'REPORT' THEN '评估报告' WHEN 'LETTER' THEN '意见函' WHEN 'CONSULT' THEN '咨询报告' ELSE '' END ) productionType,
-        assets_name,
         evaluate_amount,
         repertory_out_time
         FROM
@@ -1692,7 +1694,7 @@
         AND production_type != 'STATEMENT'
         ) ap
         LEFT JOIN ( SELECT business_id, production_no, production_should_amount, real_amount, standard_amount FROM production_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) pf
-            ON ( ap.business_id = pf.business_id AND ap.production_no = pf.production_no )
+        ON ( ap.business_id = pf.business_id AND ap.production_no = pf.production_no )
         LEFT JOIN ( SELECT business_id,should_amount FROM order_fund WHERE business_type = 'ASSET_BUSINESS' AND deleted = 0 ) `of` ON `of`.business_id = ap.business_id
         LEFT JOIN assets a ON a.id = ap.business_id
         LEFT JOIN user u ON u.id = a.client_manager_id
@@ -1723,7 +1725,7 @@
                     #{userId}
                 </foreach>
             </if>
-        order by overdueDay desc
+        order by overdueDay asc
     </sql>
 
     <!--资产收款逾期列表-->

+ 16 - 0
domain/src/main/java/com/dayou/dto/history/HisPersonalProduction.java

@@ -0,0 +1,16 @@
+package com.dayou.dto.history;
+
+import lombok.Data;
+
+import java.util.Date;
+
+@Data
+public class HisPersonalProduction {
+
+    private String id;
+
+    private Date  bgInRepoTime;
+
+    private Date  bgOutRepoTime;
+
+}

+ 71 - 2
service/src/main/java/com/dayou/dyoa/DyoaHistoryServiceImpl.java

@@ -25,6 +25,7 @@ import com.dayou.exception.ErrorCode;
 import com.dayou.mapper.*;
 import com.dayou.service.*;
 import com.dayou.service.impl.AssetsServiceImpl;
+import com.dayou.service.impl.PersonalProductionServiceImpl;
 import com.dayou.utils.DateUtils;
 import com.dayou.utils.HttpKit;
 import lombok.extern.slf4j.Slf4j;
@@ -49,6 +50,7 @@ import java.util.stream.Collectors;
 
 import static com.dayou.common.Constants.*;
 import static com.dayou.enums.MainBusinessEnum.*;
+import static com.dayou.enums.ProductionEnum.FINAL;
 
 @DS("dyoa")
 @Service
@@ -340,6 +342,8 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
     private DyoaRecordMapper dyoaRecordMapper;
     @Autowired
     private PersonalTargetMapper personalTargetMapper;
+    @Autowired
+    private IPersonalProductionService personalProductionServiceImpl;
 
 
     @Override
@@ -1617,11 +1621,12 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
                 }
             }
             else{
-                //更新已同步产品的归档状态、归档时间、送达状态、送达时间
+                //更新已同步产品的归档状态、归档时间、送达状态、送达时间、产品出库时间
                 boolean flog = false;
                 for (MajorProduction majorProduction :list){
                     Date archiveTime = productionNo.getArchiveTime();
                     Date confirmTime = productionNo.getConfirmTime();
+                    Date bgOutTime = productionNo.getBgOutTime();
                     if (archiveTime!=null){
                         flog = true;
                         majorProduction.setIfSaveFile(true);
@@ -1632,13 +1637,19 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
                         majorProduction.setDelivery(true);
                         majorProduction.setDeliveryDate(DateUtils.dateToLocalDate(confirmTime));
                     }
+                    if (bgOutTime!=null){
+                        flog = true;
+                        majorProduction.setRepertoryOutTime(bgOutTime);
+                    }
                     if (flog){
                         majorProductionService.update(new LambdaUpdateWrapper<MajorProduction>()
                                 .eq(BaseEntity::getId,majorProduction.getId())
                                 .set(majorProduction.getIfSaveFile()!=null,MajorProduction::getIfSaveFile,majorProduction.getIfSaveFile())
                                 .set(majorProduction.getSaveFileDate()!=null,MajorProduction::getSaveFileDate,majorProduction.getSaveFileDate())
                                 .set(majorProduction.getDelivery()!=null,MajorProduction::getDelivery,majorProduction.getDelivery())
-                                .set(majorProduction.getDeliveryDate()!=null,MajorProduction::getDeliveryDate,majorProduction.getDeliveryDate()));
+                                .set(majorProduction.getDeliveryDate()!=null,MajorProduction::getDeliveryDate,majorProduction.getDeliveryDate())
+                                .set(majorProduction.getRepertoryOutTime()!=null,MajorProduction::getRepertoryOutTime,majorProduction.getRepertoryOutTime()));
+
                     }
 
                 }
@@ -1777,6 +1788,64 @@ public class DyoaHistoryServiceImpl implements IDyoaHistoryService{
     }
 
     @Override
+    public Boolean updatePersonalProduction() {
+        List<HisPersonalProduction> list = dyoaRecordMapper.findPersonalProduction();
+        for (HisPersonalProduction hisPersonalProduction : list){
+            Long personalTargetId = dyoaRecordService.getPersonalTargetId(hisPersonalProduction.getId());
+            if (personalTargetId != null){
+                PersonalTarget target = personalTargetService.getById(personalTargetId);
+                if (target!=null){
+                    PersonalProduction pp = personalProductionServiceImpl.getOne(new LambdaQueryWrapper<PersonalProduction>()
+                            .eq(PersonalProduction::getTargetId, personalTargetId));
+                    Date bgOutRepoTime = hisPersonalProduction.getBgOutRepoTime();
+                    Date bgInRepoTime = hisPersonalProduction.getBgInRepoTime();
+                    if (pp==null){
+                        PersonalProduction personalProduction = new PersonalProduction();
+
+                        personalProduction.setTargetId(personalTargetId);
+                        personalProduction.setProduction(FINAL.name());
+                        if (bgOutRepoTime!=null){
+                            personalProduction.setRepertoryState(true);
+                            personalProduction.setRepertoryOutTime(DateUtils.parseLocalDateTime(DateUtils.dateTime(bgOutRepoTime)));
+                        }
+                        if (bgInRepoTime!=null){
+                            personalProduction.setRepertoryInTime(DateUtils.parseLocalDateTime(DateUtils.dateTime(bgInRepoTime)));
+                        }
+                        personalProductionServiceImpl.save(personalProduction);
+                    }else if(pp.getRepertoryState()==null){
+                        pp.setRepertoryState(true);
+                        pp.setRepertoryOutTime(DateUtils.parseLocalDateTime(DateUtils.dateTime(bgOutRepoTime)));
+                        pp.setRepertoryInTime(DateUtils.parseLocalDateTime(DateUtils.dateTime(bgInRepoTime)));
+                        personalProductionServiceImpl.updateById(pp);
+                    }
+
+                }
+            }
+        }
+        return null;
+    }
+
+
+    @Override
+    public Boolean updateAssetsProduction() {
+        List<HisPersonalProduction> assetsProduction = dyoaRecordMapper.findAssetsProduction();
+        for (HisPersonalProduction hisPersonalProduction : assetsProduction){
+            Long assetsId = dyoaRecordService.getMbsIdByDyOAIdForAssets(hisPersonalProduction.getId());
+            if (assetsId != null && hisPersonalProduction.getBgOutRepoTime()!=null){
+                AssetsProduction ap = assetsProductionService.getOne(new LambdaQueryWrapper<AssetsProduction>().eq(AssetsProduction::getBusinessId, assetsId).eq(AssetsProduction::getProductionType,"REPORT"));
+                if (ap!=null && ap.getRepertoryState()==null){
+                        ap.setRepertoryState(true);
+                        ap.setRepertoryOutTime(DateUtils.parseLocalDateTime(DateUtils.dateTime(hisPersonalProduction.getBgOutRepoTime())));
+                        ap.setRepertoryInTime(DateUtils.parseLocalDateTime(DateUtils.dateTime(hisPersonalProduction.getBgInRepoTime())));
+                    assetsProductionService.update(ap);
+                }
+            }
+        }
+        return null;
+    }
+
+
+    @Override
     public Boolean updateProductionFund() {
         List<OrderFund> orderFunds = orderFundService.getAllOrderFund();
         for (OrderFund orderFund : orderFunds) {

+ 3 - 0
service/src/main/java/com/dayou/dyoa/IDyoaHistoryService.java

@@ -44,4 +44,7 @@ public interface IDyoaHistoryService {
 
     Boolean updateCommissionDeclare();
 
+    Boolean updatePersonalProduction();
+
+    Boolean updateAssetsProduction();
 }

+ 16 - 0
service/src/main/java/com/dayou/dyoa/task/FetchDyoaDataSchedule.java

@@ -85,4 +85,20 @@ public class FetchDyoaDataSchedule {
         log.info("更新大中型提成申报完成");
     }
 
+
+    //每天凌晨06:55触发
+    @Scheduled(cron = "0 58 6 * * ?")
+    public void updateAssetsProduction(){
+        dyoaHistoryService.updateAssetsProduction();
+        log.info("更新资产产品出入库状态");
+    }
+
+    //每天凌晨07:00触发
+    @Scheduled(cron = "0 00 7 * * ?")
+    public void updatePersonalProduction(){
+        dyoaHistoryService.updatePersonalProduction();
+        log.info("更新个贷出入库状态");
+    }
+
+
 }

+ 4 - 0
service/src/main/java/com/dayou/service/IDyoaRecordService.java

@@ -42,5 +42,9 @@ public interface IDyoaRecordService extends IService<DyoaRecord> {
 
 
     Long getMbsIdByDyOAId(String id);
+
+    Long getPersonalTargetId(String id);
+
+    Long getMbsIdByDyOAIdForAssets(String id);
 }
 

+ 10 - 0
service/src/main/java/com/dayou/service/impl/DyoaRecordServiceImpl.java

@@ -98,5 +98,15 @@ public class DyoaRecordServiceImpl extends ServiceImpl<DyoaRecordMapper, DyoaRec
         return dyoaRecordMapper.getMbsIdByDyOAId(id);
     }
 
+    @Override
+    public Long getPersonalTargetId(String id) {
+        return dyoaRecordMapper.getPersonalTargetId(id);
+    }
+
+    @Override
+    public Long getMbsIdByDyOAIdForAssets(String id) {
+        return dyoaRecordMapper.getMbsIdByDyOAIdForAssets(id);
+    }
+
 
 }

+ 2 - 0
service/src/main/java/com/dayou/service/impl/PersonalProductionServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.util.StrUtil;
 import cn.hutool.json.JSONArray;
 import cn.hutool.json.JSONUtil;
 import com.alibaba.fastjson.JSON;
+import com.baomidou.dynamic.datasource.annotation.DS;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.dayou.common.BaseEntity;
 import com.dayou.configuration.DfsConfig;
@@ -56,6 +57,7 @@ import static com.dayou.enums.ProductionEnum.*;
  * @author wucl
  * @since 2024-03-18
  */
+@DS("mbs")
 @Service
 public class PersonalProductionServiceImpl extends ServiceImpl<PersonalProductionMapper, PersonalProduction> implements IPersonalProductionService , ResourceLoaderAware {