12 changed files with 220 additions and 136 deletions
@ -0,0 +1,55 @@
@@ -0,0 +1,55 @@
|
||||
package com.ruoyi.web.controller.gss; |
||||
|
||||
import java.time.LocalDateTime; |
||||
import java.time.temporal.WeekFields; |
||||
import java.util.Calendar; |
||||
import java.util.Locale; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.security.access.prepost.PreAuthorize; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.PostMapping; |
||||
import org.springframework.web.bind.annotation.RequestMapping; |
||||
import org.springframework.web.bind.annotation.RequestParam; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
import com.ruoyi.common.core.controller.BaseController; |
||||
import com.ruoyi.common.core.domain.AjaxResult; |
||||
// 修改服务接口的导入路径
|
||||
import com.ruoyi.web.service.IReportInitializeService; |
||||
|
||||
@RestController |
||||
@RequestMapping("/gss/initialize") |
||||
public class ReportInitializeController extends BaseController { |
||||
|
||||
@Autowired |
||||
private IReportInitializeService reportInitializeService; |
||||
|
||||
@GetMapping("/currentYear") |
||||
@PreAuthorize("@ss.hasPermi('gss:initialize:query')") |
||||
public AjaxResult getCurrentYear() { |
||||
Calendar cal = Calendar.getInstance(); |
||||
return AjaxResult.success(cal.get(Calendar.YEAR)); |
||||
} |
||||
|
||||
@GetMapping("/currentWeek") |
||||
@PreAuthorize("@ss.hasPermi('gss:initialize:query')") |
||||
public AjaxResult getCurrentWeek() { |
||||
LocalDateTime dateTime = LocalDateTime.now().plusDays(3); |
||||
WeekFields weekFields = WeekFields.of(Locale.getDefault()); |
||||
int weekNumber = dateTime.get(weekFields.weekOfWeekBasedYear()); |
||||
return AjaxResult.success(weekNumber); |
||||
} |
||||
|
||||
@PostMapping("/execute") |
||||
@PreAuthorize("@ss.hasPermi('gss:initialize:add')") |
||||
public AjaxResult execute(@RequestParam String year, |
||||
@RequestParam String week, |
||||
@RequestParam String productCategory, |
||||
@RequestParam String salesAreaCode) { |
||||
try { |
||||
reportInitializeService.execute(year, week, productCategory, salesAreaCode); |
||||
return AjaxResult.success("初始化成功"); |
||||
} catch (Exception e) { |
||||
return AjaxResult.error("初始化失败:" + e.getMessage()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,15 @@
@@ -0,0 +1,15 @@
|
||||
package com.ruoyi.web.mapper; |
||||
|
||||
import com.ruoyi.system.domain.SalesAreaReport; // 修改引用路径
|
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
@Mapper |
||||
public interface ReportInitializeMapper { |
||||
int checkExists(@Param("year") String year, |
||||
@Param("week") String week, |
||||
@Param("productCategory") String productCategory, |
||||
@Param("salesAreaCode") String salesAreaCode); |
||||
|
||||
int insertSalesAreaReport(SalesAreaReport report); |
||||
} |
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
package com.ruoyi.web.service; |
||||
|
||||
public interface IReportInitializeService { |
||||
void execute(String year, String week, String productCategory, String salesAreaCode); |
||||
} |
@ -0,0 +1,36 @@
@@ -0,0 +1,36 @@
|
||||
package com.ruoyi.web.service.impl; |
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
import com.ruoyi.system.mapper.SalesAreaReportMapper; // 修改引用路径
|
||||
import com.ruoyi.system.domain.SalesAreaReport; // 修改引用路径
|
||||
import com.ruoyi.web.service.IReportInitializeService; |
||||
import com.ruoyi.common.utils.SecurityUtils; |
||||
import java.util.Date; |
||||
|
||||
@Service |
||||
public class ReportInitializeServiceImpl implements IReportInitializeService { |
||||
|
||||
@Autowired |
||||
private SalesAreaReportMapper salesAreaReportMapper; // 修改变量名
|
||||
|
||||
@Override |
||||
public void execute(String year, String week, String productCategory, String salesAreaCode) { |
||||
if (salesAreaReportMapper.checkExists(year, week, productCategory, salesAreaCode) > 0) { |
||||
return; |
||||
} |
||||
|
||||
SalesAreaReport report = new SalesAreaReport(); |
||||
report.setProductCategory(productCategory); |
||||
report.setProductCategoryName("商显"); |
||||
report.setSalesAreaCode(salesAreaCode); |
||||
report.setSalesAreaName("全部".equals(salesAreaCode) ? "全部" : "待完善"); |
||||
report.setManagerId(SecurityUtils.getUserId()); |
||||
report.setManagerName(SecurityUtils.getUsername()); |
||||
report.setReportStatus("0"); |
||||
report.setCreateBy(SecurityUtils.getUsername()); |
||||
report.setCreateTime(new Date()); |
||||
|
||||
salesAreaReportMapper.insertSalesAreaReport(report); |
||||
} |
||||
} |
@ -0,0 +1,23 @@
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
<!DOCTYPE mapper |
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||
<mapper namespace="com.ruoyi.web.mapper.ReportInitializeMapper"> |
||||
|
||||
<select id="checkExists" resultType="Integer"> |
||||
select count(1) from sales_area_report |
||||
where product_category = #{productCategory} |
||||
and sales_area_code = #{salesAreaCode} |
||||
</select> |
||||
|
||||
<insert id="insertSalesAreaReport" parameterType="com.ruoyi.system.domain.SalesAreaReport"> |
||||
insert into sales_area_report ( |
||||
product_category, product_category_name, sales_area_code, sales_area_name, |
||||
manager_id, manager_name, report_status, create_by, create_time |
||||
) values ( |
||||
#{productCategory}, #{productCategoryName}, #{salesAreaCode}, #{salesAreaName}, |
||||
#{managerId}, #{managerName}, #{reportStatus}, #{createBy}, #{createTime} |
||||
) |
||||
</insert> |
||||
|
||||
</mapper> |
@ -1,36 +1,42 @@
@@ -1,36 +1,42 @@
|
||||
package com.ruoyi.system.mapper; |
||||
|
||||
import com.ruoyi.system.domain.SalesAreaReport; |
||||
import java.util.List; |
||||
import com.ruoyi.system.domain.SalesAreaReport; |
||||
import org.apache.ibatis.annotations.Mapper; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
@Mapper |
||||
public interface SalesAreaReportMapper { |
||||
/** |
||||
* 查询区域提报列表 |
||||
*/ |
||||
public List<SalesAreaReport> selectSalesAreaReportList(SalesAreaReport salesAreaReport); |
||||
List<SalesAreaReport> selectSalesAreaReportList(SalesAreaReport salesAreaReport); |
||||
|
||||
/** |
||||
* 查询区域提报详细 |
||||
* 根据ID查询区域提报 |
||||
*/ |
||||
public SalesAreaReport selectSalesAreaReportById(Long reportId); |
||||
SalesAreaReport selectSalesAreaReportById(Long reportId); |
||||
|
||||
/** |
||||
* 新增区域提报 |
||||
* 更新区域提报 |
||||
*/ |
||||
public int insertSalesAreaReport(SalesAreaReport salesAreaReport); |
||||
int updateSalesAreaReport(SalesAreaReport report); |
||||
|
||||
/** |
||||
* 修改区域提报 |
||||
* 批量删除区域提报 |
||||
*/ |
||||
public int updateSalesAreaReport(SalesAreaReport salesAreaReport); |
||||
int deleteSalesAreaReportByIds(Long[] reportIds); |
||||
|
||||
/** |
||||
* 删除区域提报 |
||||
* 检查是否存在 |
||||
*/ |
||||
public int deleteSalesAreaReportById(Long reportId); |
||||
int checkExists(@Param("year") String year, |
||||
@Param("week") String week, |
||||
@Param("productCategory") String productCategory, |
||||
@Param("salesAreaCode") String salesAreaCode); |
||||
|
||||
/** |
||||
* 批量删除区域提报 |
||||
* 插入区域提报 |
||||
*/ |
||||
public int deleteSalesAreaReportByIds(Long[] reportIds); |
||||
int insertSalesAreaReport(SalesAreaReport report); |
||||
} |
@ -1,31 +1,19 @@
@@ -1,31 +1,19 @@
|
||||
package com.ruoyi.system.service; |
||||
|
||||
import com.ruoyi.system.domain.SalesAreaReport; |
||||
import java.util.List; |
||||
import com.ruoyi.system.domain.SalesAreaReport; |
||||
|
||||
public interface ISalesAreaReportService { |
||||
/** |
||||
* 查询区域提报列表 |
||||
*/ |
||||
public List<SalesAreaReport> selectSalesAreaReportList(SalesAreaReport salesAreaReport); |
||||
List<SalesAreaReport> selectSalesAreaReportList(SalesAreaReport salesAreaReport); |
||||
|
||||
/** |
||||
* 查询区域提报详细 |
||||
*/ |
||||
public SalesAreaReport selectSalesAreaReportById(Long reportId); |
||||
SalesAreaReport selectSalesAreaReportById(Long reportId); |
||||
|
||||
/** |
||||
* 新增区域提报 |
||||
*/ |
||||
public int insertSalesAreaReport(SalesAreaReport salesAreaReport); |
||||
int updateSalesAreaReport(SalesAreaReport report); |
||||
|
||||
/** |
||||
* 修改区域提报 |
||||
*/ |
||||
public int updateSalesAreaReport(SalesAreaReport salesAreaReport); |
||||
int deleteSalesAreaReportByIds(Long[] reportIds); |
||||
|
||||
/** |
||||
* 删除区域提报信息 |
||||
* 新增区域提报 |
||||
*/ |
||||
public int deleteSalesAreaReportByIds(Long[] reportIds); |
||||
int insertSalesAreaReport(SalesAreaReport salesAreaReport); |
||||
} |
Loading…
Reference in new issue