| | |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcEquipmentOvertime; |
| | | import org.jeecg.modules.mdc.entity.MdcNoplanClose; |
| | | import org.jeecg.modules.mdc.mapper.MdcEquipmentOvertimeMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentOvertimeService; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.util.DateUtils; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.math.RoundingMode; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | |
| | | //获取当前登录用户 |
| | | //update-begin---author:wangshuai ---date:20211227 for:[JTC-116]导出人写死了------------ |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("加班管理列表数据", "导出人:"+user.getRealname(), "加班管理")); |
| | | mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("加班管理列表数据", "导出人:" + user.getRealname(), "加班管理")); |
| | | //update-end---author:wangshuai ---date:20211227 for:[JTC-116]导出人写死了------------ |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, mdcEquipmentOvertimes); |
| | | return mv; |
| | | } |
| | | |
| | | /** |
| | | * 计算加班时间(分钟) |
| | | * |
| | | * @param equipmentId |
| | | * @param validDate |
| | | * @return |
| | | */ |
| | | @Override |
| | | public BigDecimal computeOvertime(String equipmentId, String validDate) { |
| | | List<MdcEquipmentOvertime> list = this.baseMapper.computeOvertime(equipmentId, validDate.replaceAll("-", "")); |
| | | BigDecimal result = new BigDecimal("0"); |
| | | if (list != null && !list.isEmpty()) { |
| | | for (MdcEquipmentOvertime equipmentOvertime : list) { |
| | | result = result.add(equipmentOvertime.getDuration().divide(new BigDecimal("60"), 0, RoundingMode.HALF_UP)); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param mdcEquipmentOvertime |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean addOvertime(MdcEquipmentOvertime mdcEquipmentOvertime) { |
| | | String[] equipmentIds = mdcEquipmentOvertime.getEquipmentId().split(","); |
| | | List<MdcEquipmentOvertime> mdcEquipmentOvertimes = new ArrayList<>(); |
| | | // 计算时长(秒) |
| | | String startTime = mdcEquipmentOvertime.getStartTime(); |
| | | String endTime = mdcEquipmentOvertime.getEndTime(); |
| | | long duration = DateUtils.differentSecond(DateUtils.setTimeForDay(DateUtils.getNow(), startTime), DateUtils.setTimeForDay(DateUtils.getNow(), endTime)); |
| | | for (String equipmentId : equipmentIds) { |
| | | MdcEquipmentOvertime equipmentOvertime = new MdcEquipmentOvertime(); |
| | | equipmentOvertime.setEquipmentId(equipmentId); |
| | | equipmentOvertime.setTheDate(mdcEquipmentOvertime.getTheDate()); |
| | | equipmentOvertime.setAutoFlag(CommonConstant.AUTO_FLAG_N); |
| | | equipmentOvertime.setStartTime(mdcEquipmentOvertime.getStartTime()); |
| | | equipmentOvertime.setEndTime(mdcEquipmentOvertime.getEndTime()); |
| | | equipmentOvertime.setDuration(new BigDecimal(duration)); |
| | | mdcEquipmentOvertimes.add(equipmentOvertime); |
| | | } |
| | | return super.saveBatch(mdcEquipmentOvertimes); |
| | | } |
| | | } |