浏览代码

1.修改工时汇总删除审核中数据

WoNiu 4 年之前
父节点
当前提交
3e4ccbf534

+ 8 - 0
src/main/java/com/galaxis/manatee/dao/ChuanyunMemberCostDao.java

@@ -5,6 +5,7 @@ import com.galaxis.capsule.util.GalaxisRepository;
 import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunMemberCostDO;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -41,4 +42,11 @@ public interface ChuanyunMemberCostDao extends GalaxisRepository<ChuanyunMemberC
      * @return  人员-项目工时
      */
     ChuanyunMemberCostDO findByUserIdAndProjectIdAndStatus(String userId,String projectId,String status);
+
+    /**
+     * 删除审核中数据
+     * @param status
+     */
+    @Transactional
+    void deleteAllByStatus(String status);
 }

+ 3 - 0
src/main/java/com/galaxis/manatee/dao/ChuanyunProjectCostDao.java

@@ -5,6 +5,7 @@ import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunMemberCostDO;
 import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunProjectCostDO;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -39,4 +40,6 @@ public interface ChuanyunProjectCostDao extends GalaxisRepository<ChuanyunProjec
      */
     ChuanyunProjectCostDO findByProjectId(String projectId);
 
+    @Transactional
+    void deleteAllByStatus(String status);
 }

+ 8 - 0
src/main/java/com/galaxis/manatee/dao/ChuanyunSelfCostDao.java

@@ -6,6 +6,7 @@ import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunSelfWorkHourDO;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.data.repository.query.Param;
 import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -30,4 +31,11 @@ public interface ChuanyunSelfCostDao extends GalaxisRepository<ChuanyunSelfCostD
     @Query(value="SELECT * FROM chuanyun_self_cost WHERE user_id = ?1 AND project_id = ?2 AND DATE_FORMAT(chuanyun_self_cost.day_log_date,'%Y-%m')=DATE_FORMAT(?3,'%Y-%m')",nativeQuery = true)
     ChuanyunSelfCostDO getOldSelfDO(@Param("userId")String userId,@Param("projectId")String projectId,@Param("dayLogDate")String dayLogDate);
 
+    /**
+     * 根据流程状态删除数据
+     * @param status
+     */
+    @Transactional
+    void deleteAllByStatus(String status);
+
 }

+ 2 - 0
src/main/java/com/galaxis/manatee/dao/ChuanyunWeekMemberHourDao.java

@@ -5,6 +5,7 @@ import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunProjectCostDO;
 import com.galaxis.manatee.entity.chuanyun.data.object.ChuanyunWeekMemberHourDO;
 import org.springframework.data.jpa.repository.Query;
 import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 
@@ -16,6 +17,7 @@ public interface ChuanyunWeekMemberHourDao extends GalaxisRepository<ChuanyunWee
      * @param status    状态
      * @return  删除条数
      */
+    @Transactional
     Integer deleteAllByStatus(String status);
 
     /**

+ 21 - 0
src/main/java/com/galaxis/manatee/entity/chuanyun/data/object/ChuanyunCommonDO.java

@@ -0,0 +1,21 @@
+package com.galaxis.manatee.entity.chuanyun.data.object;
+
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.persistence.Entity;
+
+@Slf4j
+@EqualsAndHashCode(callSuper = true)
+@Data
+@Entity
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ChuanyunCommonDO extends BasicDO{
+
+    @JsonProperty("OwnerId")
+    private String ownerId;
+}

+ 11 - 13
src/main/java/com/galaxis/manatee/task/ChuanyunProjectScheduledTask.java

@@ -237,6 +237,8 @@ public class ChuanyunProjectScheduledTask {
     @Scheduled(fixedDelay = 3600000L)
     private void projectHour() {
         List<ChuanyunProjectCostDO> list1 = chuanyunProjectCostDao.getProjectCost();
+        deleteExamineStatus(ChuanyunProjectTotalCostDO.SCHEMA_CODE,"F0000006");
+        chuanyunProjectCostDao.deleteAllByStatus("2");
         list1.forEach(chuanyunProjectCostDO -> {
             //获取项目实施费用
             ChuanyunReimbursementAmountDO chuanyunReimbursementAmountDO = chuanyunReimbursementAmountDao.getAmount(chuanyunProjectCostDO.getProjectId());
@@ -417,7 +419,7 @@ public class ChuanyunProjectScheduledTask {
     private void standardWeeklyWorkHour() {
         long start=Instant.now().getEpochSecond();
         //删除数据库中审批中的数据,防止重复记录工时
-//        chuanyunWeekMemberHourDao.deleteAllByStatus("2");
+        chuanyunWeekMemberHourDao.deleteAllByStatus("2");
         //更新数据库
         log.info("开始周工时标准化");
         List<ChuanyunWeekMemberHourDO> list = chuanyunWeekMemberHourDao.getWeekMemberHour();
@@ -472,19 +474,12 @@ public class ChuanyunProjectScheduledTask {
         //每月每项目工时,按月-项目-用户分组统计标准工时
         List<ChuanyunSelfWorkHourDO> list = chuanyunSelfWorkHourDao.getMonthProjectHour(chuanyunUserCompanyDO.getUserId());
         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        //删除审核中数据
+        chuanyunSelfCostDao.deleteAllByStatus("2");
         list.forEach(projectMonth->{
             //获取人员-月度-相同工时状态标准工时汇总
             ChuanyunSelfWorkHourDO monthHour = chuanyunSelfWorkHourDao.getMonthHour(projectMonth.getUserId(),df.format(projectMonth.getDayLogDate()),projectMonth.getStatus());
-            //获取人员月度工资信息
-            //TODO 张曦铭的薪资信息同步之后需要使用U9中的数据更新薪资信息
-//            ChuanyunPayrollDO chuanyunPayrollDO = chuanyunPayrollDao.getPayroll(projectMonth.getUserId(),df.format(projectMonth.getDayLogDate()));
-
-//            if (chuanyunPayrollDO != null) {
-//                BigDecimal cost = (projectMonth.getStandardWorkHour().divide(monthHour.getStandardWorkHour(), 2, RoundingMode.HALF_UP)).multiply(chuanyunPayrollDO.getWagesPayable());
-//                chuanyunSelfCostDO.setCost(cost);
-//            }else{
-//                chuanyunSelfCostDO.setCost(BigDecimal.ZERO);
-//            }
+
             ChuanyunSelfCostDO chuanyunSelfCostDO = new ChuanyunSelfCostDO();
             chuanyunSelfCostDO.setStatus(projectMonth.getStatus());
             chuanyunSelfCostDO.setMonthlyTotalHour(monthHour.getStandardWorkHour());
@@ -508,6 +503,8 @@ public class ChuanyunProjectScheduledTask {
     @Scheduled(fixedDelay = 3600000L)
     private void projectTotalHour() {
         List<ChuanyunMemberCostDO> list = chuanyunMemberCostDao.getMemberCost();
+        deleteExamineStatus(ChuanyunProjectMemberCostDO.SCHEMA_CODE,"F0000007");
+        chuanyunMemberCostDao.deleteAllByStatus("2");
         list.forEach(chuanyunMemberCostDO -> {
             if(StringUtils.isEmpty(chuanyunMemberCostDO.getProjectId())||StringUtils.isEmpty(chuanyunMemberCostDO.getUserId())){
                 log.info("########"+chuanyunMemberCostDO+"");
@@ -626,6 +623,7 @@ public class ChuanyunProjectScheduledTask {
         var pageSize = 20;
         var page = 0;
         log.info("开始更新周工时汇总");
+        deleteExamineStatus(ChuanyunProjectMemberWeekHourDO.SCHEMA_CODE,"F0000007");
         long startTime=Instant.now().getEpochSecond();
         while(flag) {
             var pageable = PageRequest.of(page, pageSize);
@@ -753,10 +751,10 @@ public class ChuanyunProjectScheduledTask {
         try {
             List<String> matchers = new ArrayList<>();
             matchers.add(buttonCode+"_2,"+"2");
-            var filter= Filter.instance(0,1,true,"And",matchers);
+            var filter= Filter.instance(0,Integer.MAX_VALUE,true,"And",matchers);
             var chuanyunFindAllResponse=chuanYunManager.findAll(schemaCode,filter);
             if (chuanyunFindAllResponse.getReturnData()!=null){
-                List<BasicDO> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
+                List<ChuanyunCommonDO> result=objectMapper.convertValue(chuanyunFindAllResponse.getReturnData().getBizObjectArray(), new TypeReference<>(){});
                 result.forEach(basicDO -> {
                     ChuanyunSaveDTO chuanyunSaveDTO = chuanYunManager.delete(schemaCode,basicDO.getObjectId());
                     if(chuanyunSaveDTO.getSuccessful()){