Преглед изворни кода

新增每年处理最大公出接口

anderx пре 1 година
родитељ
комит
7c23e5d9c9

+ 0 - 2
src/main/java/com/goafanti/common/controller/PublicController.java

@@ -977,6 +977,4 @@ public class PublicController extends CertifyApiController {
 		res.data("ok");
 		return res;
 	}
-
-
 }

+ 16 - 6
src/main/java/com/goafanti/common/mapper/PublicReleaseMapper.xml

@@ -777,14 +777,24 @@
         </if>
         <if test="type==6">
             and a.type=0 and a.assist=1
-            and a.id in (select pr.main_id
-            from public_release pr left join admin_public_reviewer apr on
-            pr.aid = apr.aid
-            where  pr.`type` =3 and apr.type = 1
-            and apr.reviewer_id = #{aid})
+            and a.id in (select pr.main_id from public_release pr left join admin_public_reviewer apr
+                    on pr.aid = apr.aid where  pr.`type` =3 and apr.type = 1 and apr.reviewer_id = #{aid})
         </if>
         <if test="type==7">
-            and opc.max_process =#{configType}
+            and opc.max_process in (1,2,3,4,5)
+            <if test="maxProcessStatus ==null">
+                and opc.max_process >= #{configType}
+            </if>
+            <if test="maxProcessStatus ==0">
+                and opc.max_process= #{configType}
+            </if>
+            <if test="maxProcessStatus ==1">
+                and opc.max_process > #{configType}
+                and opc.max_process in (1,2,3,5)
+            </if>
+            <if test="maxProcessStatus ==2">
+                and opc.max_process =4
+            </if>
         </if>
         <if test="clockIn !=null">
             and a.clock_in =#{clockIn}

+ 10 - 7
src/main/java/com/goafanti/common/mapper/TOrderNewMapper.xml

@@ -1057,30 +1057,33 @@ left join department d on o.order_dep = d.id   left join t_order_mid a on o.orde
 
   <sql id="selectOrderNewSql">
     <if test="specially ==12">
+      <if test="maxStatus !=null">
+        and toprc.max_status = #{maxStatus}
+      </if>
       <if test="manageType==0">
-        <if test="maxProcessStatus =null">
+        <if test="maxProcessStatus ==null">
           and toprc.max_process >= #{configType}
         </if>
-        <if test="maxProcessStatus =0">
+        <if test="maxProcessStatus ==0">
           and toprc.max_process= #{configType}
         </if>
-        <if test="maxProcessStatus =1">
+        <if test="maxProcessStatus ==1">
           and toprc.max_process > #{configType}
           and toprc.max_process in (1,2,3,5)
         </if>
-        <if test="maxProcessStatus =2">
+        <if test="maxProcessStatus ==2">
           and toprc.max_process =4
         </if>
       </if>
         <if test="manageType==1">
           and toprc.max_process  in (1,2,3,4,5)
-          <if test="maxProcessStatus =0">
+          <if test="maxProcessStatus ==0">
             and toprc.max_process  in (1,2,3)
           </if>
-          <if test="maxProcessStatus =1">
+          <if test="maxProcessStatus ==1">
             and toprc.max_process  in (5)
           </if>
-          <if test="maxProcessStatus =2">
+          <if test="maxProcessStatus ==2">
             and toprc.max_process  in (4)
           </if>
         </if>

+ 17 - 4
src/main/java/com/goafanti/common/task/YearReportTask.java

@@ -1,19 +1,23 @@
 package com.goafanti.common.task;
 
-import javax.annotation.Resource;
-
+import com.goafanti.common.model.TOrderNew;
+import com.goafanti.common.utils.LoggerUtils;
+import com.goafanti.order.service.OrderNewService;
+import com.goafanti.order.service.OrderReportService;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
-import com.goafanti.common.utils.LoggerUtils;
-import com.goafanti.order.service.OrderReportService;
+import javax.annotation.Resource;
+import java.util.List;
 
 @Component
 public class YearReportTask {
 	@Resource
 	private  OrderReportService	orderReportServiceImpl;
+	@Resource
+	private OrderNewService orderNewService;
 
 	Logger	logger	= LoggerFactory.getLogger(YearReportTask.class);
 	/**
@@ -25,5 +29,14 @@ public class YearReportTask {
     	//新增年数据
     	int c = orderReportServiceImpl.saveLastYearReportData();
     	LoggerUtils.debug(logger, "统计去年订单【%s】条。", c);
+		//处理订单年份金额计算
+		pushOrderMaxDuration();
     }
+
+	private void pushOrderMaxDuration() {
+		List<TOrderNew> tOrderNews = orderNewService.selectOrderByAmount();
+		for (TOrderNew e : tOrderNews) {
+			orderNewService.pushOrderPublicReleaseCount(e);
+		}
+	}
 }

+ 2 - 0
src/main/java/com/goafanti/order/service/OrderNewService.java

@@ -243,4 +243,6 @@ public interface OrderNewService {
 	String pushOrderGetDunContent(TOrderNew e);
 
 	void pushOrderMaxDuration();
+
+	List<TOrderNew> selectOrderByAmount();
 }

+ 44 - 8
src/main/java/com/goafanti/order/service/impl/OrderNewServiceImpl.java

@@ -52,6 +52,7 @@ import java.math.BigDecimal;
 import java.math.RoundingMode;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.util.*;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
@@ -774,6 +775,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			orderYearMaxDuration.setOrderNo(orderNew.getOrderNo());
 			orderYearMaxDurationMapper.insert(orderYearMaxDuration);
 		}else {
+			//会员的处理
 			for (TTaskMember e : tTaskMembers) {
 				if (e.getYearSum()!=null&&e.getYearSum()>yearSum){
 					yearSum=e.getYearSum();
@@ -785,11 +787,14 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 			if (strings != null) {
 				collect = strings.stream().map(this::extractYear).collect(Collectors.toList());
 				int size = collect.size();
+				//算出来平均值
 				BigDecimal divide = orderNew.getTotalAmount().divide(new BigDecimal(size), RoundingMode.HALF_EVEN);
 				maxDuration = pushMaxDuration(divide);
+				BigDecimal yearMax=BigDecimal.ZERO;
+				//如果是无限制或者限制公出则无需判定年份只有是限制需要单独判定
+				boolean flag=false;
                 for (Integer year : collect) {
 					OrderYearMaxDuration orderYearMaxDuration = new OrderYearMaxDuration();
-					orderYearMaxDuration.setYear(year);
 					//需修改成判定
 					if (maxDuration.compareTo(new BigDecimal(-1))==0){
 						orderYearMaxDuration.setMaxDuration(BigDecimal.ZERO);
@@ -803,10 +808,11 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 						out.setMaxDuration(BigDecimal.ZERO.doubleValue());
 						out.setMaxType(0);
 					}else {
-						orderYearMaxDuration.setMaxDuration(maxDuration);
+						yearMax = yearMax.add(maxDuration);
+						orderYearMaxDuration.setYear(year);
+						orderYearMaxDuration.setMaxDuration(yearMax);
 						orderYearMaxDuration.setStatus(0);
-						out.setMaxDuration(maxDuration.doubleValue());
-						out.setMaxType(1);
+						flag=true;
 					}
 					orderYearMaxDuration.setOrderNo(orderNew.getOrderNo());
                     int x = orderYearMaxDurationMapper.queryAllByCount(new OrderYearMaxDuration(orderNew.getOrderNo(), year));
@@ -816,6 +822,16 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 						orderYearMaxDurationMapper.insert(orderYearMaxDuration);
 					}
 				}
+				if(flag){
+					List<OrderYearMaxDuration> orderYearMaxDurations = orderYearMaxDurationMapper.selectByOrderNo(orderNew.getOrderNo());
+					// 获取当前日期,提取当前年份
+					LocalDate currentDate = LocalDate.now();
+					int currentYear = currentDate.getYear();
+					OrderYearMaxDuration matchedYearOrLast = findMatchedYearOrLast(orderYearMaxDurations, currentYear);
+					out.setMaxDuration(matchedYearOrLast.getMaxDuration().doubleValue());
+					out.setMaxType(1);
+				}
+
 			}else {
 				//异常单处理
 				OrderYearMaxDuration orderYearMaxDuration = new OrderYearMaxDuration();
@@ -848,7 +864,16 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 				}
 			}
 		}
-		if(out.getMaxProcess()==null)out.setMaxProcess(4);
+		if(out.getMaxProcess()==null)out.setMaxProcess(0);
+	}
+
+	private OrderYearMaxDuration findMatchedYearOrLast(List<OrderYearMaxDuration> orderYearMaxDurations, int currentYear) {
+		for (OrderYearMaxDuration e : orderYearMaxDurations) {
+			if (e.getYear()==currentYear){
+				return e;
+			}
+		}
+		return orderYearMaxDurations.get(orderYearMaxDurations.size()-1);
 	}
 
 	private  Integer extractYear(String yearStr) {
@@ -860,6 +885,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		throw new BusinessException("年份提取失败");
 	}
 
+
 	@Override
 	public List<TOrderNew> selectGetAll() {
 		return tOrderNewMapper.selectgetAll();
@@ -1269,6 +1295,7 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 		if (StringUtils.isNotBlank(in.getName())) {
 			params.put("name", in.getName());
 		}
+		if(in.getMaxProcessStatus()!=null)params.put("maxProcessStatus", in.getMaxProcessStatus());
 		// 计算出所有本部门及所属部门的ID
 		if(in.getSpecially()==1|| in.getSpecially()==5) {
 			List<String>departmentList=new ArrayList<>();
@@ -1328,7 +1355,6 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 				params.put("type", split);
 			}
 		}
-		if(in.getMaxStatus()!=null)params.put("maxStatus", in.getMaxStatus());
 		params.put("outsource", in.getOutsource());
 		return null;
 	}
@@ -2620,11 +2646,21 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
 
 	@Override
 	public void pushOrderMaxDuration() {
-//		List<TOrderNew> tOrderNews = tOrderNewMapper.selectgetAll();
+		List<TOrderNew> tOrderNews = tOrderNewMapper.selectgetAll();
 //		for (TOrderNew e : tOrderNews) {
-		TOrderNew e = tOrderNewMapper.selectByPrimaryKey("759707486285873152");
+		TOrderNew e = tOrderNewMapper.selectByPrimaryKey("1032662365591977984");
 		pushOrderPublicReleaseCount(e);
+
 //		}
 	}
 
+	@Override
+	public List<TOrderNew> selectOrderByAmount() {
+		List<TOrderNew> tOrderNews = tOrderNewMapper.selectgetAll();
+		List<TOrderNew> collect = tOrderNews.stream().filter(e ->
+				e.getTotalAmount().compareTo(new BigDecimal(1)) > 0 && e.getTotalAmount().compareTo(new BigDecimal(10)) < 1
+		).collect(Collectors.toList());
+		return collect;
+	}
+
 }

+ 9 - 0
src/main/java/com/goafanti/weChat/bo/InputPublicReleaseList.java

@@ -14,6 +14,7 @@ public class InputPublicReleaseList {
 	 *  此处 0是 非+主  1是所有 2是子协单
 	 */
 	private Integer assist;
+	private Integer maxProcessStatus;
 //	公出时间搜索,按公出名称搜索,按审核状态搜索(审核中、已撤销、已审核),按打卡状态搜索(已打卡、未打卡)
 	private String releaseStarts;
 	private String releaseEnds;
@@ -21,6 +22,14 @@ public class InputPublicReleaseList {
 	private String status;
 	private String clockIn;
 
+	public Integer getMaxProcessStatus() {
+		return maxProcessStatus;
+	}
+
+	public void setMaxProcessStatus(Integer maxProcessStatus) {
+		this.maxProcessStatus = maxProcessStatus;
+	}
+
 	public Integer getAssist() {
 		return assist;
 	}

+ 1 - 0
src/main/java/com/goafanti/weChat/service/impl/PublicReleaseServiceImpl.java

@@ -762,6 +762,7 @@ public class PublicReleaseServiceImpl extends BaseMybatisDao<PublicReleaseMapper
 				configType=3;
 			}
 			map.put("configType", configType);
+			if (in.getMaxProcessStatus()!=null)map.put("maxProcessStatus", in.getMaxProcessStatus());
 		}
 // 		if(in.getType()==4)map.put("type", 5);
 		if (in.getType()==3) {

+ 2 - 2
src/main/resources/props/config_local.properties

@@ -1,8 +1,8 @@
 dev.name=local
 jdbc.driverClassName=com.mysql.jdbc.Driver
 
-#static.host=//static.jishutao.com/1.3.25
-static.host=//172.16.1.187/1.3.25
+static.host=//static.jishutao.com/1.3.25
+#static.host=//172.16.1.187/1.3.25
 
 #jdbc.url=jdbc\:mysql://localhost:3306/aft20240430?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false
 #jdbc.url=jdbc\:mysql://localhost:3306/aft?useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&useSSL=false