提交 45586cee authored 作者: 李秋林's avatar 李秋林

后端管理接口更新

上级 b78bcd61
package com.wangxiaolu.promotion.controller.activity.employee;
import com.wangxiaolu.promotion.enums.activity.TemActApproveStatus;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.activity.temporary.employee.vo.ApproveVO;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activity.employee.EmployeeCoreTemActivityService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author : liqiulin
* @date : 2024-06-03 14
* @describe : 员工操作审批
*/
@Slf4j
@RestController
@RequestMapping("/activity/employee/core")
public class EmployeeCoreTemActivityController {
@Autowired
EmployeeCoreTemActivityService employeeCoreTemActivityService;
/**
* 员工审批上报活动数据
*/
@PostMapping("/approve/{id}")
public R approveActivity(@PathVariable("id") long reportedId,@RequestBody ApproveVO approveVO) {
if (TemActApproveStatus.SEND_BACK.equals(approveVO.getApproveStatus()) && StringUtils.isBlank(approveVO.getApproveReason())){
throw new ParamException(RCode.SEND_BACK_REASON_NOT,null);
}
employeeCoreTemActivityService.approveActivity(reportedId,approveVO);
return R.success();
}
}
...@@ -32,4 +32,5 @@ public class EmployeeQueryTemActivityController { ...@@ -32,4 +32,5 @@ public class EmployeeQueryTemActivityController {
return R.success(pageInfo); return R.success(pageInfo);
} }
} }
package com.wangxiaolu.promotion.controller.activity.employee;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.result.basedata.R;
import com.wangxiaolu.promotion.service.activity.employee.EmployeeQueryTemClockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
/**
* @author : liqiulin
* @date : 2024-05-29 14
* @describe : 员工查询促销员活动上报信息
*/
@Slf4j
@RestController
@RequestMapping("/activity/employee/query")
public class EmployeeQueryTemClockController {
@Autowired
EmployeeQueryTemClockService employeeQueryTemClockService;
/**
* 查询员工打卡记录
*/
@PostMapping("/clock/page")
public R findClockList(@RequestHeader("loginQcId") String loginQcId, @RequestBody PageInfo pageInfo) {
employeeQueryTemClockService.findClockList(loginQcId, pageInfo);
return R.success(pageInfo);
}
}
...@@ -44,4 +44,13 @@ public class TemporaryActivityClockQueryController { ...@@ -44,4 +44,13 @@ public class TemporaryActivityClockQueryController {
TemporaryClockDto clockDto = temporaryActivityClockQueryService.findTemporaryClockByTemIdAndDate(temporaryId, createDate); TemporaryClockDto clockDto = temporaryActivityClockQueryService.findTemporaryClockByTemIdAndDate(temporaryId, createDate);
return R.success(clockDto); return R.success(clockDto);
} }
/**
* 根据ID查询打卡记录
*/
@GetMapping("/id")
public R findTemporaryClockByTemIdAndDate(Long id) {
TemporaryClockDto clockDto = temporaryActivityClockQueryService.findById(id);
return R.success(clockDto);
}
} }
package com.wangxiaolu.promotion.domain.activity.dao; package com.wangxiaolu.promotion.domain.activity.dao;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper; import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto;
/** /**
...@@ -26,4 +27,17 @@ public interface TemporaryActivityClockDao { ...@@ -26,4 +27,17 @@ public interface TemporaryActivityClockDao {
* @return 上述条件只能满足一条记录 * @return 上述条件只能满足一条记录
*/ */
TemporaryClockDto selectOne(TemporaryClockWrapper tcw); TemporaryClockDto selectOne(TemporaryClockWrapper tcw);
/**
* 员工查询负责的促销员打卡信息(分页查询)
*/
void employeePage(String employeeQcId, PageInfo pageInfo);
/**
* 员工查询负责的促销员打卡信息(分页查询)
*/
} }
...@@ -5,14 +5,23 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; ...@@ -5,14 +5,23 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao; import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao;
import com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityClockMapper; import com.wangxiaolu.promotion.domain.activity.mapper.TemporaryActivityClockMapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO; import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityReportedDO;
import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper; import com.wangxiaolu.promotion.domain.activity.wrapperQo.TemporaryClockWrapper;
import com.wangxiaolu.promotion.exception.DataException;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto; import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryClockDto;
import com.wangxiaolu.promotion.result.basedata.RCode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
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 org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
/** /**
...@@ -63,6 +72,26 @@ public class TemporaryActivityClockDaoImpl implements TemporaryActivityClockDao ...@@ -63,6 +72,26 @@ public class TemporaryActivityClockDaoImpl implements TemporaryActivityClockDao
return transitionDto(clockDO); return transitionDto(clockDO);
} }
@Override
public void employeePage(String employeeQcId, PageInfo pageInfo) {
// pagesize*(pageIndex - 1)
int pageSize = pageInfo.getPageSize();
int pageNum = pageInfo.getPageNum();
int skipNum = pageSize * (pageNum - 1);
List<TemporaryActivityClockDO> clockDOS = temporaryActivityClockMapper.employeePageFirsd(employeeQcId, pageSize, skipNum);
if (Objects.isNull(clockDOS)) {
throw new DataException(RCode.DATA_NOT_HAVE_ERROR);
}
List<TemporaryClockDto> temporaryClockDtos = transitionDtos(clockDOS);
pageInfo.setRecords(temporaryClockDtos);
// 查询总数
Integer total = temporaryActivityClockMapper.employeePageCount(employeeQcId, pageInfo.getPageSize());
pageInfo.setTotalRecord(total);
}
private LambdaQueryWrapper<TemporaryActivityClockDO> buildWrapper(TemporaryClockWrapper tcw) { private LambdaQueryWrapper<TemporaryActivityClockDO> buildWrapper(TemporaryClockWrapper tcw) {
LambdaQueryWrapper<TemporaryActivityClockDO> qw = new LambdaQueryWrapper<>(); LambdaQueryWrapper<TemporaryActivityClockDO> qw = new LambdaQueryWrapper<>();
if (Objects.nonNull(tcw.getId())) { if (Objects.nonNull(tcw.getId())) {
...@@ -80,6 +109,25 @@ public class TemporaryActivityClockDaoImpl implements TemporaryActivityClockDao ...@@ -80,6 +109,25 @@ public class TemporaryActivityClockDaoImpl implements TemporaryActivityClockDao
return qw; return qw;
} }
/**
* DO to DTO (单个对象)
*
* @param temDos DO对象List
* @return DTO对象
*/
private List<TemporaryClockDto> transitionDtos(List<TemporaryActivityClockDO> temDos) {
if (CollectionUtils.isEmpty(temDos)) {
return new ArrayList<>();
}
List<TemporaryClockDto> dtos = new ArrayList<>(temDos.size() * 2);
for (TemporaryActivityClockDO temDo : temDos) {
dtos.add(transitionDto(temDo));
}
return dtos;
}
private TemporaryClockDto transitionDto(TemporaryActivityClockDO clockDO) { private TemporaryClockDto transitionDto(TemporaryActivityClockDO clockDO) {
TemporaryClockDto dto = null; TemporaryClockDto dto = null;
if (Objects.isNull(clockDO)) { if (Objects.isNull(clockDO)) {
......
...@@ -3,18 +3,25 @@ package com.wangxiaolu.promotion.domain.activity.mapper; ...@@ -3,18 +3,25 @@ package com.wangxiaolu.promotion.domain.activity.mapper;
import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO; import com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* @author a02200059 * @author a02200059
* @description 针对表【temporary_activity_clock】的数据库操作Mapper * @description 针对表【temporary_activity_clock】的数据库操作Mapper
* @createDate 2024-04-23 17:10:46 * @createDate 2024-04-23 17:10:46
* @Entity com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO * @Entity com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO
*/ */
@Mapper @Mapper
@Repository @Repository
public interface TemporaryActivityClockMapper extends BaseMapper<TemporaryActivityClockDO> { public interface TemporaryActivityClockMapper extends BaseMapper<TemporaryActivityClockDO> {
List<TemporaryActivityClockDO> employeePageFirsd(@Param("employeeQcId") String employeeQcId, @Param("pageSize") int pageSize, @Param("skipNum") int skipNum);
// List<TemporaryActivityClockDO> employeePage(@Param("employeeQcId") String employeeQcId, @Param("pageSize") int pageSize, @Param("maxId") Integer maxId);
Integer employeePageCount(@Param("employeeQcId") String employeeQcId, @Param("pageSize") int pageSize);
} }
......
...@@ -68,6 +68,11 @@ public class TemporaryActivityReportedDO implements Serializable { ...@@ -68,6 +68,11 @@ public class TemporaryActivityReportedDO implements Serializable {
*/ */
private Date approveTime; private Date approveTime;
/**
* 退回原因
*/
private String approveReason;
private Integer sellXiangA; private Integer sellXiangA;
private Integer sellXiangB; private Integer sellXiangB;
private Integer sellXiangC; private Integer sellXiangC;
......
...@@ -17,6 +17,8 @@ public enum LogType { ...@@ -17,6 +17,8 @@ public enum LogType {
t_1(1,"打卡"), t_1(1,"打卡"),
t_2(2,"活动数据保存"), t_2(2,"活动数据保存"),
t_3(3,"活动数据提交审批"), t_3(3,"活动数据提交审批"),
t_4(4,"活动数据审批退回"),
t_5(5,"活动数据审批通过"),
; ;
private Integer type; private Integer type;
......
...@@ -73,6 +73,11 @@ public class TemporaryActivityReportedDto { ...@@ -73,6 +73,11 @@ public class TemporaryActivityReportedDto {
*/ */
private Date approveTime; private Date approveTime;
/**
* 退回原因
*/
private String approveReason;
/** /**
* 推广试吃照片 * 推广试吃照片
*/ */
......
package com.wangxiaolu.promotion.pojo.activity.temporary.employee.vo;
import com.wangxiaolu.promotion.enums.activity.TemActApproveStatus;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author : liqiulin
* @date : 2024-06-03 14
* @describe :
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ApproveVO {
/**
* 审批状态
*/
TemActApproveStatus approveStatus;
/**
* 退回理由
*/
String approveReason;
}
package com.wangxiaolu.promotion.service.activity.employee;
import com.wangxiaolu.promotion.pojo.activity.temporary.employee.vo.ApproveVO;
/**
* @author : liqiulin
* @date : 2024-06-03 14
* @describe :
*/
public interface EmployeeCoreTemActivityService {
void approveActivity(long reportedId, ApproveVO approveVO);
}
package com.wangxiaolu.promotion.service.activity.employee;
import com.wangxiaolu.promotion.pojo.PageInfo;
/**
* @author : liqiulin
* @date : 2024-06-03 16
* @describe :
*/
public interface EmployeeQueryTemClockService {
void findClockList(String employeeQcId, PageInfo pageInfo);
}
package com.wangxiaolu.promotion.service.activity.employee.impl;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityLogDao;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityReportedDao;
import com.wangxiaolu.promotion.enums.activity.LogType;
import com.wangxiaolu.promotion.enums.activity.TemActApproveStatus;
import com.wangxiaolu.promotion.exception.ParamException;
import com.wangxiaolu.promotion.pojo.activity.temporary.dto.TemporaryActivityReportedDto;
import com.wangxiaolu.promotion.pojo.activity.temporary.employee.vo.ApproveVO;
import com.wangxiaolu.promotion.result.basedata.RCode;
import com.wangxiaolu.promotion.service.activity.employee.EmployeeCoreTemActivityService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.Objects;
/**
* @author : liqiulin
* @date : 2024-06-03 14
* @describe :
*/
@Slf4j
@Service
public class EmployeeCoreTemActivityServiceImpl implements EmployeeCoreTemActivityService {
@Autowired
TemporaryActivityReportedDao temporaryActivityReportedDao;
@Autowired
private TemporaryActivityLogDao tempActivityLogDao;
@Transactional(rollbackFor = Exception.class)
@Override
public void approveActivity(long reportedId, ApproveVO approveVO) {
TemporaryActivityReportedDto reportedDto = temporaryActivityReportedDao.findOneById(reportedId);
if (Objects.isNull(reportedDto)) {
throw new ParamException(RCode.DATA_NOT_HAVE_ERROR, null);
}
if (reportedDto.getApproveStatus().equals(approveVO.getApproveStatus())) {
throw new ParamException(RCode.APPROVE_STATUS_REPETITION, null);
}
TemporaryActivityReportedDto temActDto = new TemporaryActivityReportedDto()
.setId(reportedId)
.setApproveStatus(approveVO.getApproveStatus())
.setApproveTime(new Date())
.setApproveReason(approveVO.getApproveReason());
temporaryActivityReportedDao.updateById(temActDto);
// 写日志
LogType logType = TemActApproveStatus.APPROVED.equals(approveVO.getApproveStatus()) ? LogType.t_5 : LogType.t_4;
tempActivityLogDao.save(reportedDto.getTemporaryId(), reportedDto.getTemporaryName(), logType, temActDto.getId(), temActDto);
}
}
package com.wangxiaolu.promotion.service.activity.employee.impl;
import com.wangxiaolu.promotion.domain.activity.dao.TemporaryActivityClockDao;
import com.wangxiaolu.promotion.pojo.PageInfo;
import com.wangxiaolu.promotion.service.activity.employee.EmployeeQueryTemClockService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author : liqiulin
* @date : 2024-06-03 16
* @describe :
*/
@Service
@Slf4j
public class EmployeeQueryTemClockServiceImpl implements EmployeeQueryTemClockService {
@Autowired
TemporaryActivityClockDao temporaryActivityClockDao;
@Override
public void findClockList(String employeeQcId, PageInfo pageInfo) {
temporaryActivityClockDao.employeePage(employeeQcId,pageInfo);
}
}
...@@ -11,4 +11,6 @@ public interface TemporaryActivityClockQueryService { ...@@ -11,4 +11,6 @@ public interface TemporaryActivityClockQueryService {
TemporaryClockDto findTodayTemporaryClockByTemId(Integer temporaryId); TemporaryClockDto findTodayTemporaryClockByTemId(Integer temporaryId);
TemporaryClockDto findTemporaryClockByTemIdAndDate(Integer temporaryId, String createDate); TemporaryClockDto findTemporaryClockByTemIdAndDate(Integer temporaryId, String createDate);
TemporaryClockDto findById(Long id);
} }
...@@ -52,6 +52,14 @@ public class TemporaryActivityClockQueryServiceImpl implements TemporaryActivity ...@@ -52,6 +52,14 @@ public class TemporaryActivityClockQueryServiceImpl implements TemporaryActivity
return temporaryClockDto; return temporaryClockDto;
} }
@Override
public TemporaryClockDto findById(Long id) {
TemporaryClockWrapper tcw = new TemporaryClockWrapper().setId(id);
TemporaryClockDto temporaryClockDto = temporaryActivityClockDao.selectOne(tcw);
findClockPhoto(temporaryClockDto);
return temporaryClockDto;
}
/** /**
* 查询打卡图片 * 查询打卡图片
*/ */
......
...@@ -6,33 +6,13 @@ ...@@ -6,33 +6,13 @@
<resultMap id="BaseResultMap" type="com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO"> <resultMap id="BaseResultMap" type="com.wangxiaolu.promotion.domain.activity.mapper.entity.TemporaryActivityClockDO">
<id property="id" column="id" jdbcType="BIGINT"/> <id property="id" column="id" jdbcType="BIGINT"/>
<result property="temporaryId" column="temporary_id" jdbcType="INTEGER"/>
<result property="temporaryName" column="temporary_name" jdbcType="VARCHAR"/> <result property="temporaryName" column="temporary_name" jdbcType="VARCHAR"/>
<result property="storeQcId" column="store_qc_id" jdbcType="VARCHAR"/>
<result property="storeName" column="store_name" jdbcType="VARCHAR"/> <result property="storeName" column="store_name" jdbcType="VARCHAR"/>
<result property="clockInAddress" column="clock_in_address" jdbcType="VARCHAR"/>
<result property="clockInCoordinates" column="clock_in_coordinates" jdbcType="VARCHAR"/>
<result property="clockInPhoto" column="clock_in_photo" jdbcType="VARCHAR"/>
<result property="clockInPhotoFieldId" column="clock_in_photo_field_id" jdbcType="VARCHAR"/>
<result property="clockInTime" column="clock_in_time" jdbcType="TIMESTAMP"/> <result property="clockInTime" column="clock_in_time" jdbcType="TIMESTAMP"/>
<result property="noonClockOutAddress" column="noon_clock_out_address" jdbcType="VARCHAR"/>
<result property="noonClockOutCoordinates" column="noon_clock_out_coordinates" jdbcType="VARCHAR"/>
<result property="noonClockOutPhoto" column="noon_clock_out_photo" jdbcType="VARCHAR"/>
<result property="noonClockOutPhotoFieldId" column="noon_clock_out_photo_field_id" jdbcType="VARCHAR"/>
<result property="noonClockOutTime" column="noon_clock_out_time" jdbcType="TIMESTAMP"/> <result property="noonClockOutTime" column="noon_clock_out_time" jdbcType="TIMESTAMP"/>
<result property="noonClockInAddress" column="noon_clock_in_address" jdbcType="VARCHAR"/>
<result property="noonClockInCoordinates" column="noon_clock_in_coordinates" jdbcType="VARCHAR"/>
<result property="noonClockInPhoto" column="noon_clock_in_photo" jdbcType="VARCHAR"/>
<result property="noonClockInPhotoFieldId" column="noon_clock_in_photo_field_id" jdbcType="VARCHAR"/>
<result property="noonClockInTime" column="noon_clock_in_time" jdbcType="TIMESTAMP"/> <result property="noonClockInTime" column="noon_clock_in_time" jdbcType="TIMESTAMP"/>
<result property="clockOutAddress" column="clock_out_address" jdbcType="VARCHAR"/>
<result property="clockOutCoordinates" column="clock_out_coordinates" jdbcType="VARCHAR"/>
<result property="clockOutPhoto" column="clock_out_photo" jdbcType="VARCHAR"/>
<result property="clockOutPhotoFieldId" column="clock_out_photo_field_id" jdbcType="VARCHAR"/>
<result property="clockOutTime" column="clock_out_time" jdbcType="TIMESTAMP"/> <result property="clockOutTime" column="clock_out_time" jdbcType="TIMESTAMP"/>
<result property="createDate" column="create_date" jdbcType="CHAR"/> <result property="createDate" column="create_date" jdbcType="CHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="modifyTime" column="modify_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
...@@ -47,4 +27,48 @@ ...@@ -47,4 +27,48 @@
clock_out_time,create_date,create_time, clock_out_time,create_date,create_time,
modify_time modify_time
</sql> </sql>
<select id="employeePageFirsd" resultMap="BaseResultMap">
select tc.id,
tc.temporary_name,
tc.create_date,
tc.store_name,
tc.clock_in_time,
tc.noon_clock_out_time,
tc.noon_clock_in_time,
tc.clock_out_time
from temporary_info ti
inner join temporary_activity_clock tc on ti.id = tc.temporary_id
where tc.id &lt;= (select max(id)
from temporary_activity_clock)
and ti.charger_qc_id = #{employeeQcId}
order by id desc
limit #{skipNum}, #{pageSize};
</select>
<select id="employeePage" resultMap="BaseResultMap">
select tc.id,
tc.temporary_name,
tc.create_date,
tc.store_name,
tc.clock_in_time,
tc.noon_clock_out_time,
tc.noon_clock_in_time,
tc.clock_out_time
from temporary_info ti
inner join temporary_activity_clock tc on ti.id = tc.temporary_id
where tc.id &lt; #{maxId}
and ti.charger_qc_id = #{employeeQcId}
order by id desc limit #{pageSize};
</select>
<select id="employeePageCount" resultType="integer">
select count(*)
from temporary_info ti
inner join temporary_activity_clock tc on ti.id = tc.temporary_id
where tc.id &lt;= (select max(id)
from temporary_activity_clock)
and ti.charger_qc_id = #{employeeQcId}
</select>
</mapper> </mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论