|
@@ -49,9 +49,12 @@ import java.io.File;
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
|
import java.io.UnsupportedEncodingException;
|
|
import java.io.UnsupportedEncodingException;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.regex.Matcher;
|
|
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.zip.ZipEntry;
|
|
import java.util.zip.ZipEntry;
|
|
|
import java.util.zip.ZipOutputStream;
|
|
import java.util.zip.ZipOutputStream;
|
|
@@ -707,9 +710,9 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
* @param orderNo
|
|
* @param orderNo
|
|
|
*/
|
|
*/
|
|
|
public TOrderPublicReleaseCount pushOrderPublicReleaseCount(String orderNo) {
|
|
public TOrderPublicReleaseCount pushOrderPublicReleaseCount(String orderNo) {
|
|
|
- //获取所有公出、订单与会员信息
|
|
|
|
|
|
|
+ //获取公出信息
|
|
|
List<PublicRelease> list = publicReleaseMapper.selectByOrderNo(orderNo);
|
|
List<PublicRelease> list = publicReleaseMapper.selectByOrderNo(orderNo);
|
|
|
- TOrderNewBo t = tOrderNewMapper.getOrderNewDetail(orderNo);
|
|
|
|
|
|
|
+ TOrderNew orderNew = tOrderNewMapper.selectByPrimaryKey(orderNo);
|
|
|
//公出时间统计
|
|
//公出时间统计
|
|
|
BigDecimal durationCount = BigDecimal.ZERO;
|
|
BigDecimal durationCount = BigDecimal.ZERO;
|
|
|
//公出次数
|
|
//公出次数
|
|
@@ -729,12 +732,64 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
out.setActualDuration(durationCount.doubleValue());
|
|
out.setActualDuration(durationCount.doubleValue());
|
|
|
out.setPeopleCount(peopleList.size());
|
|
out.setPeopleCount(peopleList.size());
|
|
|
out.setFrequency(count);
|
|
out.setFrequency(count);
|
|
|
-// pushMaxDuration(t,out);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //获取会员信息
|
|
|
|
|
+ List<TTaskMember> tTaskMembers = tTaskMemberMapper.selectByOrderNo(orderNo);
|
|
|
|
|
+ int yearSum=0;
|
|
|
|
|
+ String serviceLife = null;
|
|
|
|
|
+ for (TTaskMember e : tTaskMembers) {
|
|
|
|
|
+ if (e.getYearSum()!=null&&e.getYearSum()>yearSum){
|
|
|
|
|
+ yearSum=e.getYearSum();
|
|
|
|
|
+ serviceLife=e.getServiceLife();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ List<String> strings = JSON.parseArray(serviceLife, String.class);
|
|
|
|
|
+ List<Integer> collect = null;
|
|
|
|
|
+ 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);
|
|
|
|
|
+ BigDecimal maxDuration = pushMaxDuration(divide);
|
|
|
|
|
+ int i = 1;
|
|
|
|
|
+ for (Integer year : collect) {
|
|
|
|
|
+ OrderYearMaxDuration orderYearMaxDuration = new OrderYearMaxDuration();
|
|
|
|
|
+ orderYearMaxDuration.setYear(year);
|
|
|
|
|
+ if (maxDuration.compareTo(new BigDecimal(-1))==0){
|
|
|
|
|
+ orderYearMaxDuration.setMaxDuration(BigDecimal.ZERO);
|
|
|
|
|
+ orderYearMaxDuration.setStatus(1);
|
|
|
|
|
+ }else {
|
|
|
|
|
+ orderYearMaxDuration.setMaxDuration(maxDuration.multiply(new BigDecimal(i)));
|
|
|
|
|
+ orderYearMaxDuration.setStatus(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ orderYearMaxDuration.setOrderNo(orderNo);
|
|
|
|
|
+ System.out.println(orderYearMaxDuration);
|
|
|
|
|
+ i++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+//
|
|
|
|
|
+// List<String> yearsStrList = Arrays.asList("2019年", "2020年", "2021年(增)");
|
|
|
|
|
+// List<Integer> yearsIntList = yearsStrList.stream()
|
|
|
|
|
+// .map(this::extractYear)
|
|
|
|
|
+// .collect(Collectors.toList());
|
|
|
|
|
+//
|
|
|
|
|
+// System.out.println(yearsIntList);
|
|
|
|
|
+
|
|
|
return out;
|
|
return out;
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private Integer extractYear(String yearStr) {
|
|
|
|
|
+ Pattern pattern = Pattern.compile("(\\d{4})");
|
|
|
|
|
+ Matcher matcher = pattern.matcher(yearStr);
|
|
|
|
|
+ if (matcher.find()) {
|
|
|
|
|
+ return Integer.parseInt(matcher.group(1));
|
|
|
|
|
+ }
|
|
|
|
|
+ throw new BusinessException("年份提取失败");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public List<TOrderNew> selectGetAll() {
|
|
public List<TOrderNew> selectGetAll() {
|
|
|
return tOrderNewMapper.selectgetAll();
|
|
return tOrderNewMapper.selectgetAll();
|
|
@@ -785,12 +840,9 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 处理订单公出&报销最大公出
|
|
* 处理订单公出&报销最大公出
|
|
|
- * @param t
|
|
|
|
|
- * @param out
|
|
|
|
|
*/
|
|
*/
|
|
|
- private void pushMaxDuration(TOrderNewBo t,TOrderPublicReleaseCount out ) {
|
|
|
|
|
|
|
+ private BigDecimal pushMaxDuration(BigDecimal totalAmount) {
|
|
|
BigDecimal res=BigDecimal.ZERO;
|
|
BigDecimal res=BigDecimal.ZERO;
|
|
|
- BigDecimal totalAmount=t.getTotalAmount()==null?BigDecimal.ZERO:t.getTotalAmount();
|
|
|
|
|
int status=1;
|
|
int status=1;
|
|
|
if (totalAmount.compareTo(BigDecimal.valueOf(1)) < 0) {
|
|
if (totalAmount.compareTo(BigDecimal.valueOf(1)) < 0) {
|
|
|
res=BigDecimal.ZERO;
|
|
res=BigDecimal.ZERO;
|
|
@@ -805,10 +857,8 @@ public class OrderNewServiceImpl extends BaseMybatisDao<TOrderNewMapper> impleme
|
|
|
|
|
|
|
|
} else if (totalAmount.compareTo(BigDecimal.valueOf(10))>=0) {
|
|
} else if (totalAmount.compareTo(BigDecimal.valueOf(10))>=0) {
|
|
|
res=BigDecimal.valueOf(-1);
|
|
res=BigDecimal.valueOf(-1);
|
|
|
- status=0;
|
|
|
|
|
}
|
|
}
|
|
|
- out.setMaxDuration(res.doubleValue());
|
|
|
|
|
- out.setStatus(status);
|
|
|
|
|
|
|
+ return res;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|