|
|
@ -2,35 +2,68 @@ package com.ruoyi.web.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.ruoyi.system.mapper.SalesAreaReportMapper; // 修改引用路径
|
|
|
|
import com.ruoyi.system.mapper.SalesAreaReportMapper; |
|
|
|
import com.ruoyi.system.domain.SalesAreaReport; // 修改引用路径
|
|
|
|
import com.ruoyi.system.domain.SalesAreaReport; |
|
|
|
import com.ruoyi.web.service.IReportInitializeService; |
|
|
|
import com.ruoyi.web.service.IReportInitializeService; |
|
|
|
import com.ruoyi.common.utils.SecurityUtils; |
|
|
|
import com.ruoyi.common.utils.SecurityUtils; |
|
|
|
|
|
|
|
import com.ruoyi.system.domain.SalesRegion; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Date; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import com.ruoyi.system.mapper.SalesRegionMapper; |
|
|
|
|
|
|
|
import java.util.Calendar; |
|
|
|
|
|
|
|
|
|
|
|
@Service |
|
|
|
@Service |
|
|
|
public class ReportInitializeServiceImpl implements IReportInitializeService { |
|
|
|
public class ReportInitializeServiceImpl implements IReportInitializeService { |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private SalesAreaReportMapper salesAreaReportMapper; // 修改变量名
|
|
|
|
private SalesAreaReportMapper salesAreaReportMapper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
|
|
private SalesRegionMapper salesRegionMapper; // 添加销售区域Mapper注入
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void execute(String year, String week, String productCategory, String salesAreaCode) { |
|
|
|
public void execute(String year, String week, String productCategory, String salesAreaCode) { |
|
|
|
if (salesAreaReportMapper.checkExists(year, week, productCategory, salesAreaCode) > 0) { |
|
|
|
if ("all".equals(salesAreaCode)) { |
|
|
|
return; |
|
|
|
// 获取所有启用的销售区域
|
|
|
|
|
|
|
|
SalesRegion query = new SalesRegion(); |
|
|
|
|
|
|
|
query.setStatus("0"); // 只查询启用的销售区域
|
|
|
|
|
|
|
|
List<SalesRegion> regions = salesRegionMapper.selectSalesRegionList(query); |
|
|
|
|
|
|
|
for (SalesRegion region : regions) { |
|
|
|
|
|
|
|
createReport(year, week, productCategory, region.getRegionId().toString(), region.getRegionName()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
SalesRegion region = salesRegionMapper.selectSalesRegionById(Long.valueOf(salesAreaCode)); |
|
|
|
|
|
|
|
if (region != null) { |
|
|
|
|
|
|
|
createReport(year, week, productCategory, salesAreaCode, region.getRegionName()); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void createReport(String year, String week, String productCategory, String salesAreaCode, String salesAreaName) { |
|
|
|
SalesAreaReport report = new SalesAreaReport(); |
|
|
|
SalesAreaReport report = new SalesAreaReport(); |
|
|
|
|
|
|
|
// 根据年份和周次设置报告时间
|
|
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); |
|
|
|
|
|
|
|
calendar.clear(); |
|
|
|
|
|
|
|
calendar.set(Calendar.YEAR, Integer.parseInt(year)); |
|
|
|
|
|
|
|
calendar.set(Calendar.WEEK_OF_YEAR, Integer.parseInt(week)); |
|
|
|
|
|
|
|
calendar.set(Calendar.DAY_OF_WEEK, Calendar.MONDAY); |
|
|
|
|
|
|
|
report.setReportTime(calendar.getTime()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (salesAreaReportMapper.checkExists(year,week,productCategory,salesAreaCode) > 0) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
report.setProductCategory(productCategory); |
|
|
|
report.setProductCategory(productCategory); |
|
|
|
report.setProductCategoryName("商显"); |
|
|
|
report.setProductCategoryName("商显"); |
|
|
|
report.setSalesAreaCode(salesAreaCode); |
|
|
|
report.setSalesAreaCode(salesAreaCode); |
|
|
|
report.setSalesAreaName("全部".equals(salesAreaCode) ? "全部" : "待完善"); |
|
|
|
report.setSalesAreaName(salesAreaName); |
|
|
|
report.setManagerId(SecurityUtils.getUserId()); |
|
|
|
report.setManagerId(SecurityUtils.getUserId()); |
|
|
|
report.setManagerName(SecurityUtils.getUsername()); |
|
|
|
report.setManagerName(SecurityUtils.getUsername()); |
|
|
|
report.setReportStatus("0"); |
|
|
|
report.setReportStatus("0"); |
|
|
|
report.setCreateBy(SecurityUtils.getUsername()); |
|
|
|
report.setCreateBy(SecurityUtils.getUsername()); |
|
|
|
report.setCreateTime(new Date()); |
|
|
|
report.setCreateTime(new Date()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
salesAreaReportMapper.insertSalesAreaReport(report); |
|
|
|
salesAreaReportMapper.insertSalesAreaReport(report); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |