|
|
@@ -4,10 +4,7 @@ import com.goafanti.admin.bo.*;
|
|
|
import com.goafanti.admin.service.AdminStatisticsService;
|
|
|
import com.goafanti.common.constant.AFTConstants;
|
|
|
import com.goafanti.common.dao.*;
|
|
|
-import com.goafanti.common.model.Admin;
|
|
|
-import com.goafanti.common.model.AdminUserCount;
|
|
|
-import com.goafanti.common.model.PublicRelease;
|
|
|
-import com.goafanti.common.model.SalesTeam;
|
|
|
+import com.goafanti.common.model.*;
|
|
|
import com.goafanti.common.utils.DateUtils;
|
|
|
import com.goafanti.common.utils.LoggerUtils;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
@@ -43,7 +40,7 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
|
|
|
@Resource
|
|
|
private UserFollowMapper userFollowMapper;
|
|
|
@Resource
|
|
|
- private NewOrderDunMapper newOrderDunMapper;
|
|
|
+ private DepartmentMapper departmentMapper;
|
|
|
|
|
|
|
|
|
@Override
|
|
|
@@ -545,51 +542,48 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
|
|
|
List<AdminPublicDuration> list=new ArrayList<>();
|
|
|
List<String> errors=new ArrayList<>();
|
|
|
for (PublicRelease e : publicReleases) {
|
|
|
- String adminName = getAdminName(e.getAid());
|
|
|
+ AdminPublicDuration a = new AdminPublicDuration();
|
|
|
+ pushAdminNameAndProvince(e.getAid(),a);
|
|
|
+
|
|
|
//计算时间差,再加一天就是一共多少天
|
|
|
long daysBetween = DateUtils.getDaysBetween(e.getReleaseStart(), e.getReleaseEnd());
|
|
|
daysBetween+=1;
|
|
|
if (daysBetween==1){
|
|
|
- AdminPublicDuration a = new AdminPublicDuration();
|
|
|
a.setId(e.getAid());
|
|
|
a.setDate(e.getReleaseStart());
|
|
|
a.setDuration(e.getDuration());
|
|
|
- a.setName(adminName);
|
|
|
list.add(a);
|
|
|
}else if(daysBetween>0){
|
|
|
double v = e.getDuration() / daysBetween;
|
|
|
for (int i = 0; i < daysBetween; i++) {
|
|
|
LocalDate localDate1 = e.getReleaseStart().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(i);
|
|
|
if (localDate1.isBefore(endDate)){
|
|
|
- AdminPublicDuration a = new AdminPublicDuration();
|
|
|
a.setId(e.getAid());
|
|
|
a.setDate(Date.from(localDate1.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
a.setDuration(v);
|
|
|
- a.setName(adminName);
|
|
|
list.add(a);
|
|
|
}else{
|
|
|
- errors.add(String.format("用户[%s]公出时间[%s]超出[%s],不计入本月公出",adminName,localDate1.format(formatter),endDate.format(formatter)));
|
|
|
+ errors.add(String.format("用户[%s]公出时间[%s]超出[%s],不计入本月公出",a.getName(),localDate1.format(formatter),endDate.format(formatter)));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
for (PublicRelease e : publicReleases2) {
|
|
|
- String adminName = getAdminName(e.getAid());
|
|
|
+ AdminPublicDuration a = new AdminPublicDuration();
|
|
|
+ pushAdminNameAndProvince(e.getAid(),a);
|
|
|
long daysBetween = DateUtils.getDaysBetween(e.getReleaseStart(), e.getReleaseEnd());
|
|
|
if(daysBetween>0){
|
|
|
double v = e.getDuration() / daysBetween;
|
|
|
for (int i = 0; i < daysBetween; i++) {
|
|
|
LocalDate localDate1 = e.getReleaseStart().toInstant().atZone(ZoneId.systemDefault()).toLocalDate().plusDays(i);
|
|
|
if (localDate1.isAfter(localDate)){
|
|
|
- AdminPublicDuration a = new AdminPublicDuration();
|
|
|
a.setId(e.getAid());
|
|
|
a.setDate(Date.from(localDate1.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
|
|
a.setDuration(v);
|
|
|
- a.setName(adminName);
|
|
|
list.add(a);
|
|
|
}else{
|
|
|
- errors.add(String.format("用户[%s]公出时间[%s]小于[%s],不计入本月公出",adminName,localDate1.format(formatter),endDate.format(formatter)));
|
|
|
+ errors.add(String.format("用户[%s]公出时间[%s]小于[%s],不计入本月公出",a.getName(),localDate1.format(formatter),endDate.format(formatter)));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -623,8 +617,11 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
|
|
|
return map;
|
|
|
}
|
|
|
|
|
|
- private String getAdminName(String aid) {
|
|
|
+
|
|
|
+
|
|
|
+ private void pushAdminNameAndProvince(String aid, AdminPublicDuration a) {
|
|
|
Admin admin = adminMapper.queryById(aid);
|
|
|
+ Department department = departmentMapper.selectByPrimaryKey(admin.getDepartmentId());
|
|
|
String name = admin.getName();
|
|
|
// 去掉括号及其内部的内容
|
|
|
if (name.contains("(")){
|
|
|
@@ -634,7 +631,8 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
|
|
|
int index = name.indexOf('(');
|
|
|
name = name.substring(0, index);
|
|
|
}
|
|
|
- return name;
|
|
|
+ a.setName(name);
|
|
|
+ a.setProvince(department.getProvince());
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -651,9 +649,16 @@ public class AdminStatisticsServiceImpl implements AdminStatisticsService {
|
|
|
summary.setDuration(countDuration.doubleValue());
|
|
|
summary.setName(name);
|
|
|
summary.setCountNumber(summary.getCountNumber()+1);
|
|
|
- BigDecimal divide = BigDecimal.valueOf(summary.getDuration()).divide(BigDecimal.valueOf(7.5), 2, RoundingMode.HALF_UP);
|
|
|
- summary.setDays(divide.doubleValue());
|
|
|
- System.out.println(name+":"+summary.getDuration()+"/"+summary.getCountNumber()+"="+divide);
|
|
|
+ if (summary.getProvince()==11){
|
|
|
+ summary.setConversion(7.5);
|
|
|
+ } else if (summary.getProvince()==21){
|
|
|
+ summary.setConversion(7.0);
|
|
|
+ }
|
|
|
+ if (summary.getConversion()!=null){
|
|
|
+ BigDecimal divide = BigDecimal.valueOf(summary.getDuration()).divide(BigDecimal.valueOf(7.5), 2, RoundingMode.HALF_UP);
|
|
|
+ summary.setDays(divide.doubleValue());
|
|
|
+ System.out.println(name+":"+summary.getDuration()+"/"+summary.getCountNumber()+"="+divide);
|
|
|
+ }
|
|
|
} else {
|
|
|
AdminPublicDuration e = new AdminPublicDuration(id, name, duration);
|
|
|
BigDecimal divide = BigDecimal.valueOf(duration).divide(BigDecimal.valueOf(7.5), 2, RoundingMode.HALF_UP);
|