|
@@ -19,6 +19,7 @@ import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
@@ -26,6 +27,7 @@ import org.apache.poi.ss.usermodel.Row;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
import org.joda.time.DateTime;
|
|
|
+import org.joda.time.Minutes;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
|
@@ -45,6 +47,7 @@ import java.util.stream.Collectors;
|
|
|
* 加班申请
|
|
|
* sz
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@RestController
|
|
|
@RequestMapping("/base/workOver")
|
|
|
@Api(description = "workOver")
|
|
@@ -75,9 +78,15 @@ public class WorkOverController {
|
|
|
@Autowired
|
|
|
RabbitTemplate rabbitTemplate;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WorkShiftInfoService workShiftInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private WorkScheduleAttendanceService workScheduleAttendanceService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private WorkPersonSchedulingService workPersonSchedulingService;
|
|
|
+
|
|
|
@ApiOperation(value="创建空记录")
|
|
|
@GetMapping("create")
|
|
|
public MessageResult<WorkOver> create(){
|
|
@@ -662,4 +671,81 @@ public class WorkOverController {
|
|
|
}
|
|
|
return resultStr;
|
|
|
}
|
|
|
+
|
|
|
+ @GetMapping("updateBeginTime")
|
|
|
+ @ApiOperation(value="更新加班开始时间")
|
|
|
+ public MessageResult<Date> updateBeginTime(String workPersonId){
|
|
|
+ MessageResult<Date> messageResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ WorkOverPerson workOverPerson = workOverPersonService.get(workPersonId);
|
|
|
+ WorkOver workOver = workOverService.get(workOverPerson.getWorkOverId());
|
|
|
+ PersonPopedom personPopedom = personPopedomService.get(workOverPerson.getPersonPopedomId());
|
|
|
+
|
|
|
+ if (workOver.getStartTime().before(workOver.getCreateTime())){
|
|
|
+ //直接设置实际加班开始时间=申请加班开始时间
|
|
|
+ workOverPerson.setBeginTime(workOver.getStartTime());
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //如果加班开始时间前半小时单天人员有班次,则也设置实际加班开始时间=申请加班开始时间
|
|
|
+ DateTime startDay = new DateTime(workOver.getStartTime()).withTimeAtStartOfDay();
|
|
|
+ DateTime earlyTime = new DateTime(workOver.getStartTime()).plusMinutes(-30);
|
|
|
+
|
|
|
+ WorkPersonScheduling workPersonScheduling = workPersonSchedulingService.findByPersonIdSchedulingDay(personPopedom.getPersonId(), startDay.toDate());
|
|
|
+
|
|
|
+ if(workPersonScheduling!=null) {
|
|
|
+ String shiftIds = workPersonScheduling.getShiftIds();
|
|
|
+
|
|
|
+ if(StringUtils.isNotEmpty(shiftIds)){
|
|
|
+ String[] shiftIdArr = shiftIds.split(",");
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+
|
|
|
+ boolean exist = false;
|
|
|
+
|
|
|
+ for (String shiftId : shiftIdArr) {
|
|
|
+ WorkShiftInfo workShiftInfo = workShiftInfoService.get(shiftId);
|
|
|
+
|
|
|
+ Date workTime = sdf.parse(startDay.toString("yyyy-MM-dd") + " " + workShiftInfo.getWorkTime());
|
|
|
+ Date closingTime = sdf.parse(startDay.toString("yyyy-MM-dd") + " " + workShiftInfo.getClosingTime());
|
|
|
+
|
|
|
+ if (workTime.compareTo(earlyTime.toDate()) <= 0 && closingTime.compareTo(earlyTime.toDate()) >= 0) {
|
|
|
+ exist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(exist){
|
|
|
+ //直接设置实际加班开始时间=申请加班开始时间
|
|
|
+ workOverPerson.setBeginTime(workOver.getStartTime());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (workOverPerson.getBeginTime() != null && workOverPerson.getFinishTime() != null) {
|
|
|
+ int minutes = (int) Minutes.minutesBetween(new DateTime(workOverPerson.getBeginTime()), new DateTime(workOverPerson.getFinishTime())).getMinutes();
|
|
|
+ workOverPerson.setDuration(minutes);
|
|
|
+
|
|
|
+ int intHours = minutes / 60;
|
|
|
+ int intMinutes = minutes % 60;
|
|
|
+ workOverPerson.setDurationStr(intHours + "小时" + intMinutes + "分钟");
|
|
|
+ }
|
|
|
+
|
|
|
+ workOverPerson.setUpdateTime(new Date());
|
|
|
+ workOverPersonService.update(workOverPerson);
|
|
|
+
|
|
|
+ //todo 填写具体代码
|
|
|
+ messageResult.setData(workOverPerson.getBeginTime());
|
|
|
+ messageResult.setResult(true);
|
|
|
+ }
|
|
|
+ catch (Exception ex){
|
|
|
+ log.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ messageResult.setResult(false);
|
|
|
+ messageResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return messageResult;
|
|
|
+ }
|
|
|
}
|