fix:旧系统历史数据迁移到新系统

This commit is contained in:
lhb 2025-05-07 14:57:37 +08:00
parent d6896c1783
commit 7dd42131c0
7 changed files with 597 additions and 4 deletions

View File

@ -401,18 +401,18 @@ public class RzSalaryDetailServiceImpl implements IRzSalaryDetailService
if(sysStaffDetail.getDailyWage().doubleValue() > 0) {
//额薪资日期在工资月下一个月
calendar.set(Calendar.MONTH,1);
//全额薪资日期在工资月以前
if(sysStaff.getWagesRatioDate().before(month)) {
//全额薪资日期在工资月以前----null != sysStaff.getWagesRatioDate() &&
if(null != sysStaff.getWagesRatioDate() && sysStaff.getWagesRatioDate().before(month)) {
sysStaffDetail.setBasicSalary(sysStaffDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP)
.multiply(rzAttendanceStatistical.getRealAttendance().add(rzAttendanceStatistical.getWorkOvertimeNumber())));
}else if(sysStaff.getWagesRatioDate().after(calendar.getTime())) {
}else if(null != sysStaff.getWagesRatioDate() && sysStaff.getWagesRatioDate().after(calendar.getTime())) {
sysStaffDetail.setBasicSalary(sysStaffDetail.getDailyWage().divide(new BigDecimal("8.0"),2, RoundingMode.HALF_UP)
.multiply(rzAttendanceStatistical.getRealAttendance().add(rzAttendanceStatistical.getWorkOvertimeNumber())).multiply(new BigDecimal(Constants.SUBSIDY_PERIOD)));
}else {
//根据转正日期查询员工的打卡信息
BigDecimal att_work = new BigDecimal("0.0");
for (RzAttendance rzAttendance : att_list) {
if(rzAttendance.getAttendanceDate().before(sysStaff.getWagesRatioDate())) {
if(null != sysStaff.getWagesRatioDate() && rzAttendance.getAttendanceDate().before(sysStaff.getWagesRatioDate())) {
att_work = att_work.add(rzAttendance.getWorkSum());
}
}

View File

@ -85,5 +85,15 @@ public class RzRestaurantDetailController extends BaseController
return getDataTable(list);
}
/**
* 新旧系统切换临时处理历史数据方法
* @param
* @return
*/
@RequestMapping("/initDaka")
public String initDaka(){
return rzRestaurantDetailService.initRzRestaurantDetail();
}
}

View File

@ -0,0 +1,384 @@
package com.evo.restaurant.domain;
import java.util.Date;
import com.evo.common.annotation.Excel;
import com.evo.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* 餐饮消费明细对象 cy_consumption_info
*
* @author zhukangchao
* @date 2023-10-05
*/
public class CyConsumptionInfo extends BaseEntity
{
private static final long serialVersionUID = 1L;
/** 主键 */
private Long id;
/** 月统计id */
private Long statisticsId;
/** 日期 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date dateTime;
private String dateTime1;
public String getDateTime1() {
return dateTime1;
}
public void setDateTime1(String dateTime1) {
this.dateTime1 = dateTime1;
}
/** 姓名 */
@Excel(name = "姓名")
private String name;
/** 上班卡 */
@Excel(name = "上班卡")
private String shangBan;
/** 下班卡 */
@Excel(name = "下班卡")
private String xiaBan;
/** 工作时长 */
@Excel(name = "工作时长")
private Double duration;
/** 早餐次数 */
@Excel(name = "早餐次数")
private Long breakfastNumber;
/** 早餐补助 */
@Excel(name = "早餐补助")
private Double breakfastSubsidy;
/** 早餐个人消费 */
@Excel(name = "早餐个人消费")
private Double breakfastPersonalConsumption;
/** 早餐总消费 */
@Excel(name = "早餐总消费")
private Double breakfastSumConsumption;
/** 午餐次数 */
@Excel(name = "午餐次数")
private Long lunchNumber;
/** 午餐补助 */
@Excel(name = "午餐补助")
private Double lunchSubsidy;
/** 午餐个人消费 */
@Excel(name = "午餐个人消费")
private Double lunchPresonalConsumption;
/** 午餐总消费 */
@Excel(name = "午餐总消费")
private Double lunchSumConsumption;
/** 晚餐次数 */
@Excel(name = "晚餐次数")
private Long supperNumber;
/** 晚餐补助 */
@Excel(name = "晚餐补助")
private Double supperSubsidy;
/** 晚餐个人消费 */
@Excel(name = "晚餐个人消费")
private Double supperPersonalConsumption;
/** 晚餐总消费 */
@Excel(name = "晚餐总消费")
private Double supperSumConsumption;
/** 总补贴 */
@Excel(name = "总补贴")
private Double sumSubsidy;
/** 个人总消费 */
@Excel(name = "个人总消费")
private Double personalSumConsumption;
/** 总消费 */
@Excel(name = "总消费")
private Double sumConsumption;
/** 备用字段1 */
@Excel(name = "备用字段1")
private String sparedOne;
/** 备用字段2 */
@Excel(name = "备用字段2")
private String sparedTwo;
/** 备用字段3 */
@Excel(name = "备用字段3")
private Long sparedThree;
/** 备用字段4 */
@Excel(name = "备用字段4")
private Long sparedFour;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public Long getStatisticsId() {
return statisticsId;
}
public void setStatisticsId(Long statisticsId) {
this.statisticsId = statisticsId;
}
public void setDateTime(Date dateTime)
{
this.dateTime = dateTime;
}
public Date getDateTime()
{
return dateTime;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setShangBan(String shangBan)
{
this.shangBan = shangBan;
}
public String getShangBan()
{
return shangBan;
}
public void setXiaBan(String xiaBan)
{
this.xiaBan = xiaBan;
}
public String getXiaBan()
{
return xiaBan;
}
public void setDuration(Double duration)
{
this.duration = duration;
}
public Double getDuration()
{
return duration;
}
public void setBreakfastNumber(Long breakfastNumber)
{
this.breakfastNumber = breakfastNumber;
}
public Long getBreakfastNumber()
{
return breakfastNumber;
}
public void setBreakfastSubsidy(Double breakfastSubsidy)
{
this.breakfastSubsidy = breakfastSubsidy;
}
public Double getBreakfastSubsidy()
{
return breakfastSubsidy;
}
public void setBreakfastPersonalConsumption(Double breakfastPersonalConsumption)
{
this.breakfastPersonalConsumption = breakfastPersonalConsumption;
}
public Double getBreakfastPersonalConsumption()
{
return breakfastPersonalConsumption;
}
public void setBreakfastSumConsumption(Double breakfastSumConsumption)
{
this.breakfastSumConsumption = breakfastSumConsumption;
}
public Double getBreakfastSumConsumption()
{
return breakfastSumConsumption;
}
public void setLunchNumber(Long lunchNumber)
{
this.lunchNumber = lunchNumber;
}
public Long getLunchNumber()
{
return lunchNumber;
}
public void setLunchSubsidy(Double lunchSubsidy)
{
this.lunchSubsidy = lunchSubsidy;
}
public Double getLunchSubsidy()
{
return lunchSubsidy;
}
public void setLunchPresonalConsumption(Double lunchPresonalConsumption)
{
this.lunchPresonalConsumption = lunchPresonalConsumption;
}
public Double getLunchPresonalConsumption()
{
return lunchPresonalConsumption;
}
public void setLunchSumConsumption(Double lunchSumConsumption)
{
this.lunchSumConsumption = lunchSumConsumption;
}
public Double getLunchSumConsumption()
{
return lunchSumConsumption;
}
public void setSupperNumber(Long supperNumber)
{
this.supperNumber = supperNumber;
}
public Long getSupperNumber()
{
return supperNumber;
}
public void setSupperSubsidy(Double supperSubsidy)
{
this.supperSubsidy = supperSubsidy;
}
public Double getSupperSubsidy()
{
return supperSubsidy;
}
public void setSupperPersonalConsumption(Double supperPersonalConsumption)
{
this.supperPersonalConsumption = supperPersonalConsumption;
}
public Double getSupperPersonalConsumption()
{
return supperPersonalConsumption;
}
public void setSupperSumConsumption(Double supperSumConsumption)
{
this.supperSumConsumption = supperSumConsumption;
}
public Double getSupperSumConsumption()
{
return supperSumConsumption;
}
public void setSumSubsidy(Double sumSubsidy)
{
this.sumSubsidy = sumSubsidy;
}
public Double getSumSubsidy()
{
return sumSubsidy;
}
public void setPersonalSumConsumption(Double personalSumConsumption)
{
this.personalSumConsumption = personalSumConsumption;
}
public Double getPersonalSumConsumption()
{
return personalSumConsumption;
}
public void setSumConsumption(Double sumConsumption)
{
this.sumConsumption = sumConsumption;
}
public Double getSumConsumption()
{
return sumConsumption;
}
public void setSparedOne(String sparedOne)
{
this.sparedOne = sparedOne;
}
public String getSparedOne()
{
return sparedOne;
}
public void setSparedTwo(String sparedTwo)
{
this.sparedTwo = sparedTwo;
}
public String getSparedTwo()
{
return sparedTwo;
}
public void setSparedThree(Long sparedThree)
{
this.sparedThree = sparedThree;
}
public Long getSparedThree()
{
return sparedThree;
}
public void setSparedFour(Long sparedFour)
{
this.sparedFour = sparedFour;
}
public Long getSparedFour()
{
return sparedFour;
}
@Override
public String toString() {
return "CyConsumptionInfo [id=" + id + ", statisticsId=" + statisticsId + ", dateTime=" + dateTime + ", name="
+ name + ", shangBan=" + shangBan + ", xiaBan=" + xiaBan + ", duration=" + duration
+ ", breakfastNumber=" + breakfastNumber + ", breakfastSubsidy=" + breakfastSubsidy
+ ", breakfastPersonalConsumption=" + breakfastPersonalConsumption + ", breakfastSumConsumption="
+ breakfastSumConsumption + ", lunchNumber=" + lunchNumber + ", lunchSubsidy=" + lunchSubsidy
+ ", lunchPresonalConsumption=" + lunchPresonalConsumption + ", lunchSumConsumption="
+ lunchSumConsumption + ", supperNumber=" + supperNumber + ", supperSubsidy=" + supperSubsidy
+ ", supperPersonalConsumption=" + supperPersonalConsumption + ", supperSumConsumption="
+ supperSumConsumption + ", sumSubsidy=" + sumSubsidy + ", personalSumConsumption="
+ personalSumConsumption + ", sumConsumption=" + sumConsumption + ", sparedOne=" + sparedOne
+ ", sparedTwo=" + sparedTwo + ", sparedThree=" + sparedThree + ", sparedFour=" + sparedFour + "]";
}
}

View File

@ -1,5 +1,6 @@
package com.evo.restaurant.mapper;
import com.evo.restaurant.domain.CyConsumptionInfo;
import com.evo.restaurant.domain.RzRestaurantStatistics;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
@ -21,6 +22,8 @@ public interface RzRestaurantStatisticsMapper
*/
public RzRestaurantStatistics selectRzRestaurantStatisticsById(Long id);
public List<CyConsumptionInfo> selectRzRestaurantStatisticsById2(String name);
/**
* 查询餐饮统计列表
*
@ -55,4 +58,6 @@ public interface RzRestaurantStatisticsMapper
public List<RzRestaurantStatistics> selectRzRestaurantStatisticsByDate(Date date);
public List<RzRestaurantStatistics> selectRzRestaurantStatisticsByDate2(Date date);
}

View File

@ -30,6 +30,8 @@ public interface IRzRestaurantDetailService
*/
public String insertRzRestaurantDetail(String json);
public String initRzRestaurantDetail();
/**
* 当前时间的就餐人数
* @return

View File

@ -6,6 +6,7 @@ import com.evo.common.core.domain.AjaxResult;
import com.evo.common.utils.DateUtils;
import com.evo.common.utils.SecurityUtils;
import com.evo.common.utils.StringUtils;
import com.evo.restaurant.domain.CyConsumptionInfo;
import com.evo.restaurant.domain.RzRestaurantDetail;
import com.evo.restaurant.domain.RzRestaurantImages;
import com.evo.restaurant.domain.RzRestaurantStatistics;
@ -19,6 +20,7 @@ import com.evo.system.domain.SysStaff;
import com.evo.system.mapper.SysStaffMapper;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
@ -143,6 +145,150 @@ public class RzRestaurantDetailServiceImpl implements IRzRestaurantDetailService
cfiv.setResult(0);
return JSONObject.toJSONString(cfiv);
}
@Override
public String initRzRestaurantDetail()
{
RzRestaurantStatistics rzRestaurantStatistics = new RzRestaurantStatistics();
String dateStr = "2025-04-01";
SimpleDateFormat sdf0 = new SimpleDateFormat("yyyy-MM-dd");
try {
Date date = sdf0.parse(dateStr);
System.out.println(date);
rzRestaurantStatistics.setMonth(date);
} catch (Exception e) {
e.printStackTrace();
}
//根据日期查询统计日期内的统计信息
List<RzRestaurantStatistics> rt_list = rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsList(rzRestaurantStatistics);
//循环统计信息
/**
* 1查询出统计表需要循环的人员信息
* 2遍历统计记录 name和shang_banxia_ban不为空并且4-1到4-14日的记录字段去查询cy_consumption_info表
* 3二层循环遍历cy_consumption_info表
*/
for (RzRestaurantStatistics restaurantStatistics : rt_list) {
String name = restaurantStatistics.getName();
List<CyConsumptionInfo> cyConsumptionInfoList= rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsById2(name);
for (CyConsumptionInfo cyConsumptionInfo : cyConsumptionInfoList) {
// 创建日期格式化对象
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// Date String
Date date_time = cyConsumptionInfo.getDateTime();
String formattedDate = sdf.format(date_time);
String formattedDate1 = formattedDate + " 08:10:00";
String formattedDate2 = formattedDate + " 12:10:00";
String formattedDate3 = formattedDate + " 18:10:00";
System.out.println("Formatted Date: " + formattedDate);
SimpleDateFormat sdff = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date1 =null;
Date date2 =null;
Date date3 =null;
try {
date1 = sdff.parse(formattedDate1);
date2 = sdff.parse(formattedDate2);
date3 = sdff.parse(formattedDate3);
} catch (Exception e) {
e.printStackTrace();
}
if(cyConsumptionInfo.getBreakfastNumber()==1){
RzRestaurantDetail cyFaceInfo = new RzRestaurantDetail();
cyFaceInfo.setDate(date1);
cyFaceInfo.setStaffId(restaurantStatistics.getStaffId());
cyFaceInfo.setName(restaurantStatistics.getName());
cyFaceInfo.setTime(date1);
cyFaceInfo.setSign("早餐");
// restaurantStatistics.setBreakfastNumber(restaurantStatistics.getBreakfastNumber() + 1);
cyFaceInfo.setDelFlag(Constants.DELETE_FLAG_0);
cyFaceInfo.setCreateTime(date1);
rzRestaurantDetailMapper.insertRzRestaurantDetail(cyFaceInfo);
}
if(cyConsumptionInfo.getLunchNumber()==1){
RzRestaurantDetail cyFaceInfo = new RzRestaurantDetail();
cyFaceInfo.setDate(date2);
cyFaceInfo.setStaffId(restaurantStatistics.getStaffId());
cyFaceInfo.setName(restaurantStatistics.getName());
cyFaceInfo.setTime(date2);
cyFaceInfo.setSign("午餐");
// restaurantStatistics.setBreakfastNumber(restaurantStatistics.getBreakfastNumber() + 1);
cyFaceInfo.setDelFlag(Constants.DELETE_FLAG_0);
cyFaceInfo.setCreateTime(date2);
rzRestaurantDetailMapper.insertRzRestaurantDetail(cyFaceInfo);
}
if(cyConsumptionInfo.getSupperNumber()==1){
RzRestaurantDetail cyFaceInfo = new RzRestaurantDetail();
cyFaceInfo.setDate(date3);
cyFaceInfo.setStaffId(restaurantStatistics.getStaffId());
cyFaceInfo.setName(restaurantStatistics.getName());
cyFaceInfo.setTime(date3);
cyFaceInfo.setSign("晚餐");
// restaurantStatistics.setBreakfastNumber(restaurantStatistics.getBreakfastNumber() + 1);
cyFaceInfo.setDelFlag(Constants.DELETE_FLAG_0);
cyFaceInfo.setCreateTime(date3);
rzRestaurantDetailMapper.insertRzRestaurantDetail(cyFaceInfo);
}
}
}
//根据员工ID和打卡时间查询本月的打卡统计信息
/*List<RzRestaurantStatistics> restaurantStatistics = rzRestaurantStatisticsMapper.selectRzRestaurantStatisticsByDate2(new Date());
//增加打卡记录
RzRestaurantDetail cyFaceInfo = new RzRestaurantDetail();
cyFaceInfo.setDate(new Date());
cyFaceInfo.setStaffId(restaurantStatistics.getStaffId());
cyFaceInfo.setName(restaurantStatistics.getName());
cyFaceInfo.setTime(new Date());
//判断刷脸时间是早餐还是午餐还是晚餐
if(hour>6&&hour<9){
//说明是早餐
cyFaceInfo.setSign("早餐");
restaurantStatistics.setBreakfastNumber(restaurantStatistics.getBreakfastNumber() + 1);
}else if(hour>=11&&hour<=14){
//说明是午餐
cyFaceInfo.setSign("午餐");
restaurantStatistics.setLunchNumber(restaurantStatistics.getLunchNumber() + 1);
}else if(hour>=18&&hour<=20){
//说明是晚餐
cyFaceInfo.setSign("晚餐");
restaurantStatistics.setSupperNumber(restaurantStatistics.getSupperNumber() + 1);
}
cyFaceInfo.setDelFlag(Constants.DELETE_FLAG_0);
cyFaceInfo.setCreateTime(new Date());
int i = rzRestaurantDetailMapper.insertRzRestaurantDetail(cyFaceInfo);
if(i<1){
cfiv.setResult(2);
cfiv.setMsg("{\"Result\":1,\"Msg\":\"打卡失败\"}");
return JSONObject.toJSONString(cfiv);
}
//反写统计次数
i = rzRestaurantStatisticsMapper.updateRzRestaurantStatistics(restaurantStatistics);
if(i<1){
cfiv.setResult(2);
cfiv.setMsg("{\"Result\":1,\"Msg\":\"打卡失败\"}");
return JSONObject.toJSONString(cfiv);
}
cfiv.setMsg("{\"Result\":1,\"Msg\":\"打卡成功!\"}");
cfd.setClock_in_count(1);
cfiv.setContent(cfd);
cfiv.setResult(0);*/
return JSONObject.toJSONString("");
}
/**
* 统计当餐刷卡人数
* @return

View File

@ -32,10 +32,44 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
</resultMap>
<resultMap type="CyConsumptionInfo" id="CyConsumptionInfoResult">
<result property="id" column="id" />
<result property="statisticsId" column="statistics_id" />
<result property="createTime" column="create_time" />
<result property="dateTime" column="date_time" />
<result property="name" column="name" />
<result property="shangBan" column="shang_ban" />
<result property="xiaBan" column="xia_ban" />
<result property="duration" column="duration" />
<result property="breakfastNumber" column="breakfast_number" />
<result property="breakfastSubsidy" column="breakfast_subsidy" />
<result property="breakfastPersonalConsumption" column="breakfast_personal_consumption" />
<result property="breakfastSumConsumption" column="breakfast_sum_consumption" />
<result property="lunchNumber" column="lunch_number" />
<result property="lunchSubsidy" column="lunch_subsidy" />
<result property="lunchPresonalConsumption" column="lunch_presonal_consumption" />
<result property="lunchSumConsumption" column="lunch_sum_consumption" />
<result property="supperNumber" column="supper_number" />
<result property="supperSubsidy" column="supper_subsidy" />
<result property="supperPersonalConsumption" column="supper_personal_consumption" />
<result property="supperSumConsumption" column="supper_sum_consumption" />
<result property="sumSubsidy" column="sum_subsidy" />
<result property="personalSumConsumption" column="personal_sum_consumption" />
<result property="sumConsumption" column="sum_consumption" />
<result property="sparedOne" column="spared_one" />
<result property="sparedTwo" column="spared_two" />
<result property="sparedThree" column="spared_three" />
<result property="sparedFour" column="spared_four" />
</resultMap>
<sql id="selectRzRestaurantStatisticsVo">
select id, staff_id, dept_id, name, month, breakfast_expend, breakfast_number, breakfast_pre_sum_expend, breakfast_sum_expend, lunch_expend, lunch_number, lunch_pre_sum_expend, lunch_sum_expend, supper_expend, supper_number, supper_pre_sum_expend, supper_sum_expend, personal_sum_consumption, sum_consumption, remarks, del_flag, create_by, create_time, update_by, update_time from rz_restaurant_statistics
</sql>
<sql id="selectCyConsumptionInfoVo">
select id,statistics_id, create_time, date_time, name, shang_ban, xia_ban, duration, breakfast_number, breakfast_subsidy, breakfast_personal_consumption, breakfast_sum_consumption, lunch_number, lunch_subsidy, lunch_presonal_consumption, lunch_sum_consumption, supper_number, supper_subsidy, supper_personal_consumption, supper_sum_consumption, sum_subsidy, personal_sum_consumption, sum_consumption, spared_one, spared_two, spared_three, spared_four from cy_consumption_info
</sql>
<select id="selectRzRestaurantStatisticsList" parameterType="RzRestaurantStatistics" resultMap="RzRestaurantStatisticsResult">
<include refid="selectRzRestaurantStatisticsVo"/>
<where>
@ -56,6 +90,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</select>
<select id="selectRzRestaurantStatisticsById2" parameterType="String" resultMap="CyConsumptionInfoResult">
<include refid="selectCyConsumptionInfoVo"/>
where name = #{name}
AND date_format(date_time,'%Y%m%d') &gt;= date_format('2025-04-01','%Y%m%d')
AND date_format(date_time,'%Y%m%d') &lt;= date_format('2025-04-14','%Y%m%d')
</select>
<insert id="insertRzRestaurantStatistics" parameterType="RzRestaurantStatistics" useGeneratedKeys="true" keyProperty="id">
insert into rz_restaurant_statistics
<trim prefix="(" suffix=")" suffixOverrides=",">
@ -147,6 +188,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectRzRestaurantStatisticsVo"/>
where staff_id = #{staffId} and del_flag = '0' and DATE_FORMAT( month, '%Y%m' ) = DATE_FORMAT(#{date} , '%Y%m' )
</select>
<!-- 临时同步数据 -->
<select id="selectRzRestaurantStatisticsByDate2" resultMap="RzRestaurantStatisticsResult">
<include refid="selectRzRestaurantStatisticsVo"/>
where del_flag = '0' and DATE_FORMAT( month, '%Y%m' ) = DATE_FORMAT(#{date} , '%Y%m' )
</select>
<!-- 实习生统计信息 -->
<select id="selectRzRestaurantStatisticsByDate" resultMap="RzRestaurantStatisticsResult">
<include refid="selectRzRestaurantStatisticsVo"/>