|
@@ -7,10 +7,13 @@ import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
|
import cn.ezhizao.framework.web.controller.BaseController;
|
|
|
import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
|
import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
|
+import cn.ezhizao.project.business.company.domain.BizCompany;
|
|
|
+import cn.ezhizao.project.business.company.service.IBizCompanyService;
|
|
|
import cn.ezhizao.project.business.entrust.domain.BizEntrust;
|
|
|
import cn.ezhizao.project.business.entrust.service.IBizEntrustService;
|
|
|
import cn.ezhizao.project.business.workOrder.domain.BizWorkOrder;
|
|
|
import cn.ezhizao.project.business.workOrder.domain.BizWorkOrderExport;
|
|
|
+import cn.ezhizao.project.business.workOrder.domain.vo.EntrustVo;
|
|
|
import cn.ezhizao.project.business.workOrder.service.IBizWorkOrderService;
|
|
|
import cn.ezhizao.project.system.domain.SysCurrentMonth;
|
|
|
import cn.ezhizao.project.system.service.ISysCurrentMonthService;
|
|
@@ -18,16 +21,18 @@ import cn.ezhizao.project.tenant.domain.Tenant;
|
|
|
import cn.ezhizao.project.tenant.service.ITenantService;
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
-import io.swagger.models.auth.In;
|
|
|
-import org.aspectj.weaver.loadtime.Aj;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.sql.Date;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -47,6 +52,8 @@ public class WorkOrderCurrentController extends BaseController {
|
|
|
IBizEntrustService bizEntrustService;
|
|
|
@Resource
|
|
|
ITenantService tenantService;
|
|
|
+ @Resource
|
|
|
+ IBizCompanyService bizCompanyService;
|
|
|
|
|
|
/**
|
|
|
* 查询工单信息列表
|
|
@@ -113,8 +120,8 @@ public class WorkOrderCurrentController extends BaseController {
|
|
|
result.put("checkResult", true);
|
|
|
DateTime dateTime = new DateTime();
|
|
|
dateTime.setField(DateField.YEAR, Integer.parseInt(months.get(0).getYear()));
|
|
|
- dateTime.setField(DateField.MONTH, Integer.parseInt(months.get(0).getMonth()) - 1);
|
|
|
dateTime.setField(DateField.DAY_OF_MONTH, 1);
|
|
|
+ dateTime.setField(DateField.MONTH, Integer.parseInt(months.get(0).getMonth()) - 1);
|
|
|
result.put("currentMonth", dateTime.toString("yyyy-MM-dd"));
|
|
|
return success(result);
|
|
|
}
|
|
@@ -155,6 +162,122 @@ public class WorkOrderCurrentController extends BaseController {
|
|
|
return toAjax(status);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/importEntrust")
|
|
|
+ @Transactional
|
|
|
+ public AjaxResult importEntrust(MultipartFile file) throws Exception {
|
|
|
+ AtomicInteger failureNum = new AtomicInteger();
|
|
|
+ StringBuilder successMsg = new StringBuilder();
|
|
|
+ StringBuilder failureMsg = new StringBuilder();
|
|
|
+ try{
|
|
|
+
|
|
|
+ Long tenantId = getTenantId();
|
|
|
+ //获取当前月
|
|
|
+ SysCurrentMonth sysCurrentMonth = sysCurrentMonthService.getOne(new QueryWrapper<SysCurrentMonth>().eq("tenant_id", tenantId).eq("type", 0));
|
|
|
+ String day = "-01";
|
|
|
+ String workMonth = sysCurrentMonth.getYear() + "-" + sysCurrentMonth.getMonth() + day;
|
|
|
+ ExcelUtil<EntrustVo> util = new ExcelUtil<>(EntrustVo.class);
|
|
|
+ List<EntrustVo> entrustVos = util.importExcel(file.getInputStream());
|
|
|
+ List<EntrustVo> newEntrustList = new ArrayList<>();
|
|
|
+ entrustVos.forEach(f -> {
|
|
|
+ ArrayList<Integer> objects = new ArrayList<>();
|
|
|
+ if (f.getTaskName1().equals("是")) {
|
|
|
+ objects.add(1);
|
|
|
+ }
|
|
|
+ if (f.getTaskName2().equals("是")) {
|
|
|
+ objects.add(2);
|
|
|
+ }
|
|
|
+ if (f.getTaskName3().equals("是")) {
|
|
|
+ objects.add(3);
|
|
|
+ }
|
|
|
+ f.setCount(objects);
|
|
|
+ });
|
|
|
+
|
|
|
+ for (EntrustVo entrustVo : entrustVos) {
|
|
|
+ for (Integer integer : entrustVo.getCount()) {
|
|
|
+ EntrustVo entrustVo1 = new EntrustVo();
|
|
|
+ if (integer == 1) {
|
|
|
+ entrustVo1.setTaskId(1);
|
|
|
+ } else if (integer == 2) {
|
|
|
+ entrustVo1.setTaskId(2);
|
|
|
+ } else {
|
|
|
+ entrustVo1.setTaskId(3);
|
|
|
+ }
|
|
|
+ entrustVo1.setNo(entrustVo.getNo());
|
|
|
+ entrustVo1.setToEntrustName(entrustVo.getToEntrustName());
|
|
|
+ entrustVo1.setCompanyName(entrustVo.getCompanyName());
|
|
|
+ newEntrustList.add(entrustVo1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ newEntrustList.forEach(f -> {
|
|
|
+ try {
|
|
|
+ BizCompany company = bizCompanyService.getOne(new LambdaQueryWrapper<BizCompany>()
|
|
|
+ .eq(BizCompany::getTenantId, tenantId)
|
|
|
+ .eq(BizCompany::getName, f.getCompanyName().trim()));
|
|
|
+ if (company == null) {
|
|
|
+ failureNum.getAndIncrement();
|
|
|
+ failureMsg.append("<br/>" +"序号为"+f.getNo() +"," + "客户 " +f.getCompanyName() + "不存在");
|
|
|
+ } else {
|
|
|
+ f.setCompanyId(company.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ System.out.println(e);
|
|
|
+ }
|
|
|
+
|
|
|
+ });
|
|
|
+ //获取工单
|
|
|
+ for (EntrustVo e : newEntrustList) {
|
|
|
+ List<BizWorkOrder> bizWorkOrders = bizWorkOrderService.list(new LambdaQueryWrapper<BizWorkOrder>()
|
|
|
+ .eq(BizWorkOrder::getTenantId, tenantId)
|
|
|
+ .eq(BizWorkOrder::getIsStop, 0)
|
|
|
+ .eq(BizWorkOrder::getDeleted, 0)
|
|
|
+ .eq(BizWorkOrder::getType, 1)
|
|
|
+ .eq(BizWorkOrder::getTaskTypeId, e.getTaskId())
|
|
|
+ .eq(BizWorkOrder::getCompanyId, e.getCompanyId()));
|
|
|
+ if (bizWorkOrders== null ||bizWorkOrders.size() == 0) {
|
|
|
+ failureNum.getAndIncrement();
|
|
|
+ String s = "";
|
|
|
+ if(e.getTaskId() == 1){
|
|
|
+ s = "代理记账服务";
|
|
|
+ } else if (e.getTaskId()==2){
|
|
|
+ s = "社保代缴服务";
|
|
|
+ }else {
|
|
|
+ s = "公积金代缴服务";
|
|
|
+ }
|
|
|
+ failureMsg.append("<br/>" +"序号为"+e.getNo() +"," + "客户 " + e.getCompanyName() + " 没有"+s);
|
|
|
+ }else {
|
|
|
+ e.setWorkOrderIds(bizWorkOrders.stream().map(m -> m.getId()).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据受委托方分组
|
|
|
+ Map<String, List<EntrustVo>> map = newEntrustList.stream().collect(Collectors.groupingBy(e -> e.getToEntrustName()));
|
|
|
+ for (String s : map.keySet()) {
|
|
|
+ BizEntrust bizEntrust = new BizEntrust();
|
|
|
+ Tenant one = tenantService.getOne(new LambdaQueryWrapper<Tenant>().eq(Tenant::getAccountName, s));
|
|
|
+ bizEntrust.setToTenantId(one.getId());
|
|
|
+ bizEntrust.setWorkMonth(Date.valueOf(workMonth));
|
|
|
+ List<Long> workOrderIds = map.get(s).stream()
|
|
|
+ .flatMap(e -> e.getWorkOrderIds().stream())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ bizEntrust.setWorkOrderIds(workOrderIds);
|
|
|
+ this.addEntrust(bizEntrust);
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ if (Integer.valueOf(failureNum.toString()) > 0) {
|
|
|
+ failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
+ throw new ServiceException(failureMsg.toString());
|
|
|
+ } else {
|
|
|
+ successMsg.insert(0, "恭喜您,数据已全部导入成功");
|
|
|
+ }
|
|
|
+ return success(successMsg);
|
|
|
+ }
|
|
|
+
|
|
|
private boolean addEntrust(List<Long> workOrderId, Date paramWorkMonth, Long toTenantId) {
|
|
|
BizEntrust entrust = new BizEntrust();
|
|
|
entrust.setWorkOrderIds(workOrderId);
|
|
@@ -297,7 +420,7 @@ public class WorkOrderCurrentController extends BaseController {
|
|
|
if (bizWorkOrder.getToTenantId() == null) {
|
|
|
setTenantId(bizWorkOrder);
|
|
|
}
|
|
|
- startPage();
|
|
|
+// startPage();
|
|
|
startOrderBy();
|
|
|
// bizWorkOrder.setIsStop(0);
|
|
|
List<BizWorkOrder> list = bizWorkOrderService.getList(bizWorkOrder);
|