|
|
@@ -5,18 +5,23 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
import org.springblade.client.feign.ICorpsDescClient;
|
|
|
+import org.springblade.core.excel.util.ExcelUtil;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.core.tool.utils.CollectionUtil;
|
|
|
import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.project.entity.ServiceProject;
|
|
|
import org.springblade.project.entity.ServiceProjectFiles;
|
|
|
import org.springblade.project.entity.ServiceProjectItem;
|
|
|
+import org.springblade.project.excel.CommissionExcel;
|
|
|
+import org.springblade.project.excel.StatisticsExcel;
|
|
|
import org.springblade.project.service.ServiceProjectFilesService;
|
|
|
import org.springblade.project.service.ServiceProjectItemService;
|
|
|
import org.springblade.project.service.ServiceProjectService;
|
|
|
@@ -32,6 +37,7 @@ import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import springfox.documentation.annotations.ApiIgnore;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -892,7 +898,7 @@ public class ProjectController {
|
|
|
* @param beginTimeEnd
|
|
|
* @param actualDateStart
|
|
|
* @param actualDateEnd
|
|
|
- * @param corpName
|
|
|
+ * @param userName
|
|
|
* @param status
|
|
|
* @param branch
|
|
|
* @return
|
|
|
@@ -973,5 +979,72 @@ public class ProjectController {
|
|
|
return R.data(serviceProjectItem.getId());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 统计主营业务-任务、提成统计导出
|
|
|
+ *
|
|
|
+ * @param beginTimeStart
|
|
|
+ * @param beginTimeEnd
|
|
|
+ * @param userName
|
|
|
+ * @param taskStatus
|
|
|
+ * @param branch
|
|
|
+ */
|
|
|
+ @GetMapping("/statisticsExport")
|
|
|
+ @ApiOperation(value = "任务 提成统计导出", notes = "任务 提成统计导出")
|
|
|
+ public void statisticsExport(@RequestParam(name = "beginTimeStart", required = false) String beginTimeStart,
|
|
|
+ @RequestParam(name = "beginTimeEnd", required = false) String beginTimeEnd,
|
|
|
+ @RequestParam(name = "userName", required = false) String userName,
|
|
|
+ @RequestParam(name = "taskStatus", required = false) String taskStatus,
|
|
|
+ @RequestParam(name = "branch") String branch,
|
|
|
+ @RequestParam(name = "type") String type,
|
|
|
+ HttpServletResponse response
|
|
|
+ ){
|
|
|
+ LambdaQueryWrapper<ServiceProjectItem> itemLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ itemLambdaQueryWrapper
|
|
|
+ .eq(ServiceProjectItem::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .ge(StringUtils.isNotBlank(beginTimeStart), ServiceProjectItem::getBeginTime, beginTimeStart)
|
|
|
+ .le(StringUtils.isNotBlank(beginTimeEnd), ServiceProjectItem::getBeginTime, beginTimeEnd);
|
|
|
|
|
|
+ // 承做人
|
|
|
+ if (StringUtils.isNotBlank(userName)) {
|
|
|
+ List<User> userList = userClient.userInfoByName(userName, AuthUtil.getTenantId());
|
|
|
+ if (ObjectUtils.isNotNull(userList)) {
|
|
|
+ itemLambdaQueryWrapper.eq(ObjectUtils.isNotNull(userList), ServiceProjectItem::getUserid, userList.get(0).getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taskStatus = null;
|
|
|
+ itemLambdaQueryWrapper.orderByDesc(ServiceProjectItem::getUserid)
|
|
|
+ .eq(ServiceProjectItem::getIsDeleted, 0)
|
|
|
+ .eq(StringUtils.isNotBlank(taskStatus), ServiceProjectItem::getStatus, taskStatus)
|
|
|
+ .eq(ServiceProjectItem::getBranch, branch);
|
|
|
+ List<ServiceProjectItem> list = serviceProjectItemService.list(itemLambdaQueryWrapper);
|
|
|
+
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ list.forEach(e -> {
|
|
|
+ Long corpId = serviceProjectService.getOne(new LambdaQueryWrapper<ServiceProject>()
|
|
|
+ .eq(ServiceProject::getId, e.getPId())).getCorpId();
|
|
|
+ R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(corpId);
|
|
|
+ if (corpMessage.isSuccess() && corpMessage.getData() != null) {
|
|
|
+ e.setCornName(corpMessage.getData().getCname());
|
|
|
+ }
|
|
|
+ //承做人
|
|
|
+ R<User> userR = userClient.userInfoById(e.getUserid());
|
|
|
+ if (userR.isSuccess()) {
|
|
|
+ e.setUserName(userR.getData().getRealName());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ if (type.equals("RW")){
|
|
|
+ List<StatisticsExcel> excelList = new ArrayList<>();
|
|
|
+ if (ObjectUtil.isNotEmpty(list)){
|
|
|
+ excelList = BeanUtil.copy(list, StatisticsExcel.class);
|
|
|
+ }
|
|
|
+ ExcelUtil.export(response, "任务统计", "任务统计", excelList, StatisticsExcel.class);
|
|
|
+ }else if (type.equals("TC")){
|
|
|
+ List<CommissionExcel> excelList = BeanUtil.copy(list, CommissionExcel.class);
|
|
|
+ ExcelUtil.export(response, "提成统计", "提成统计", excelList, CommissionExcel.class);
|
|
|
+ }else {
|
|
|
+ throw new RuntimeException("用户无导出权限!");
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|