|
|
@@ -113,7 +113,38 @@ public class TwinWkEmpRotaServiceImpl implements ITwinWkEmpRotaService {
|
|
|
*/
|
|
|
@Override
|
|
|
public void sync(KnittingEmpVO data) {
|
|
|
- TwinWkEmpRota rota = selectByEmp(data.getDate(), data.getId(), data.getIn(), data.getOut());
|
|
|
+ TwinWkEmpRota rota = selectByEmp(data.getDate(), data.getId());
|
|
|
+ //2025-08-04 修改同步规则,之前是后面一条记录覆盖前一条记录,现在需要判断上下班时间
|
|
|
+ //2025-08-19 如果是周一至周六,则直接覆盖数据,
|
|
|
+ // 如果是周日,则判断上下班时间,如果已有记录上下班时间是7-15点,现在的记录是23-次日7点,则添加一条记录,其他情况就全覆盖。
|
|
|
+ if (rota.getShiftId() != null) {
|
|
|
+ if (isSunday(data.getDate()) && rota.getInTime().getHours() == 7 && rota.getOutTime().getHours() == 15
|
|
|
+ && data.getIn().getHours() == 23 && data.getOut().getHours() == 7) {
|
|
|
+ copyProperties(rota, data);
|
|
|
+ insertTwinWkEmpRota(rota);
|
|
|
+ } else {
|
|
|
+ copyProperties(rota, data);
|
|
|
+ updateTwinWkEmpRota(rota);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ copyProperties(rota, data);
|
|
|
+ insertTwinWkEmpRota(rota);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 判断是否周日
|
|
|
+ *
|
|
|
+ * @param date 日期
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ private boolean isSunday(Date date) {
|
|
|
+ java.util.Calendar calendar = java.util.Calendar.getInstance();
|
|
|
+ calendar.setTime(date);
|
|
|
+ return calendar.get(java.util.Calendar.DAY_OF_WEEK) == java.util.Calendar.SUNDAY;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void copyProperties(TwinWkEmpRota rota, KnittingEmpVO data) {
|
|
|
rota.setEmpId(data.getId());
|
|
|
rota.setEmpName(data.getName());
|
|
|
rota.setEmpTeam(data.getTeam());
|
|
|
@@ -126,12 +157,6 @@ public class TwinWkEmpRotaServiceImpl implements ITwinWkEmpRotaService {
|
|
|
}
|
|
|
String devices = deviceSet.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
|
rota.setDevices(devices);
|
|
|
- //2025-08-04 修改同步规则,之前是后面一条记录覆盖前一条记录,现在需要判断上下班时间
|
|
|
- if (rota.getShiftId() != null) {
|
|
|
- updateTwinWkEmpRota(rota);
|
|
|
- } else {
|
|
|
- insertTwinWkEmpRota(rota);
|
|
|
- }
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -139,12 +164,10 @@ public class TwinWkEmpRotaServiceImpl implements ITwinWkEmpRotaService {
|
|
|
* 按时间和员工号查询记录
|
|
|
*/
|
|
|
|
|
|
- private TwinWkEmpRota selectByEmp(Date date, String empId, Date in, Date out) {
|
|
|
+ private TwinWkEmpRota selectByEmp(Date date, String empId) {
|
|
|
TwinWkEmpRota search = new TwinWkEmpRota();
|
|
|
search.setEmpDate(date);
|
|
|
search.setEmpId(empId);
|
|
|
- search.setInTime(in);
|
|
|
- search.setOutTime(out);
|
|
|
|
|
|
List<TwinWkEmpRota> list = selectTwinWkEmpRotaList(search);
|
|
|
TwinWkEmpRota rota;
|