| | |
| | | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.jeecg.modules.mdc.constant.MdcConstant; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.mdc.entity.MdcPassRate; |
| | | import org.jeecg.modules.mdc.entity.MdcPlanClose; |
| | | import org.jeecg.modules.mdc.mapper.MdcPlanCloseMapper; |
| | | import org.jeecg.modules.mdc.service.IMdcEquipmentService; |
| | | import org.jeecg.modules.mdc.service.IMdcPlanCloseService; |
| | | import org.jeecg.modules.mdc.vo.MdcPlanCloseVo; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | | import org.jeecgframework.poi.excel.view.JeecgEntityExcelView; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.web.servlet.ModelAndView; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.math.BigDecimal; |
| | | import java.util.Arrays; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | |
| | |
| | | @Service |
| | | public class MdcPlanCloseServiceImpl extends ServiceImpl<MdcPlanCloseMapper, MdcPlanClose> implements IMdcPlanCloseService { |
| | | |
| | | @Resource |
| | | private IMdcEquipmentService mdcEquipmentService; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param userId |
| | | * @param page |
| | | * @param mdcPlanClose |
| | | * @param req |
| | | * @return |
| | | */ |
| | | @Override |
| | | public IPage<MdcPlanClose> pageList(String userId, Page<MdcPlanClose> page, MdcPlanCloseVo mdcPlanClose, HttpServletRequest req) { |
| | | List<String> equipmentIds = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(mdcPlanClose.getParentId()) && StringUtils.isEmpty(mdcPlanClose.getEquipmentId())) { |
| | | if ("2".equals(mdcPlanClose.getTypeTree())) { |
| | | //部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcPlanClose.getParentId()); |
| | | } else { |
| | | //产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcPlanClose.getParentId()); |
| | | } |
| | | } else if (StringUtils.isNotEmpty(mdcPlanClose.getEquipmentId())) { |
| | | //单台设备信息 |
| | | mdcPlanClose.setEquipmentIdList(Collections.singletonList(mdcPlanClose.getEquipmentId())); |
| | | } else { |
| | | //查询用户拥有的所有设备信息 |
| | | if ("2".equals(mdcPlanClose.getTypeTree())) { |
| | | //部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); |
| | | } else { |
| | | //产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | } |
| | | |
| | | if (mdcPlanClose.getEquipmentIdList() == null || mdcPlanClose.getEquipmentIdList().isEmpty()) { |
| | | mdcPlanClose.setEquipmentIdList(equipmentIds); |
| | | } |
| | | |
| | | if (mdcPlanClose.getEquipmentIdList() == null || mdcPlanClose.getEquipmentIdList().isEmpty()) { |
| | | return null; |
| | | } |
| | | return this.baseMapper.pageList(page, mdcPlanClose); |
| | | } |
| | | |
| | | /** |
| | | * 添加 |
| | | * |
| | | * @param mdcPlanCloseVo |
| | | * @return |
| | | */ |
| | | @Override |
| | | public boolean addPlanClose(MdcPlanCloseVo mdcPlanCloseVo) { |
| | | String[] equipmentIdList = mdcPlanCloseVo.getEquipmentIds().split(","); |
| | | List<MdcPlanClose> planCloseList = new ArrayList<>(); |
| | | for (String equipmentId : equipmentIdList) { |
| | | MdcPlanClose mdcPlanClose = new MdcPlanClose(); |
| | | mdcPlanClose.setEquipmentId(equipmentId); |
| | | mdcPlanClose.setPlanCloseType(mdcPlanCloseVo.getPlanCloseType()); |
| | | mdcPlanClose.setPlanCloseTimeLong(mdcPlanCloseVo.getPlanCloseTimeLong()); |
| | | mdcPlanClose.setTheDate(mdcPlanCloseVo.getTheDate()); |
| | | mdcPlanClose.setCloseType(mdcPlanCloseVo.getCloseType()); |
| | | mdcPlanClose.setRemark(mdcPlanClose.getRemark()); |
| | | planCloseList.add(mdcPlanClose); |
| | | } |
| | | this.saveBatch(planCloseList); |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public ModelAndView exportXls(String userId, MdcPlanCloseVo mdcPlanClose, String title) { |
| | | LambdaQueryWrapper<MdcPlanClose> queryWrapper = new LambdaQueryWrapper<>(); |
| | | List<String> equipmentIds = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(mdcPlanClose.getParentId()) && StringUtils.isEmpty(mdcPlanClose.getEquipmentId())) { |
| | | if ("2".equals(mdcPlanClose.getTypeTree())) { |
| | | //部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, mdcPlanClose.getParentId()); |
| | | } else { |
| | | //产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, mdcPlanClose.getParentId()); |
| | | } |
| | | } else if (StringUtils.isNotEmpty(mdcPlanClose.getEquipmentId())) { |
| | | //单台设备信息 |
| | | mdcPlanClose.setEquipmentIdList(Collections.singletonList(mdcPlanClose.getEquipmentId())); |
| | | } else { |
| | | //查询用户拥有的所有设备信息 |
| | | if ("2".equals(mdcPlanClose.getTypeTree())) { |
| | | //部门层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsByDepart(userId, null); |
| | | } else { |
| | | //产线层级 |
| | | equipmentIds = mdcEquipmentService.getEquipmentIdsProduction(userId, null); |
| | | } |
| | | } |
| | | if (mdcPlanClose.getEquipmentIdList() == null || mdcPlanClose.getEquipmentIdList().isEmpty()) { |
| | | mdcPlanClose.setEquipmentIdList(equipmentIds); |
| | | } |
| | | |
| | | if (mdcPlanClose.getEquipmentIdList() == null || mdcPlanClose.getEquipmentIdList().isEmpty()) { |
| | | return null; |
| | | } else { |
| | | queryWrapper.in(MdcPlanClose::getEquipmentId, mdcPlanClose.getEquipmentIdList()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcPlanClose.getEquipmentId())) { |
| | | queryWrapper.eq(MdcPlanClose::getEquipmentId, mdcPlanClose.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcPlanClose.getPlanCloseType())) { |
| | | queryWrapper.eq(MdcPlanClose::getPlanCloseType, mdcPlanClose.getPlanCloseType()); |
| | | } |
| | | if (StringUtils.isNotEmpty(mdcPlanClose.getStartTime()) && StringUtils.isNotEmpty(mdcPlanClose.getEndTime())) { |
| | | queryWrapper.between(MdcPlanClose::getTheDate, mdcPlanClose.getStartTime(), mdcPlanClose.getEndTime()); |
| | | } |
| | | queryWrapper.orderByDesc(MdcPlanClose::getTheDate).orderByDesc(MdcPlanClose::getEquipmentId); |
| | | ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
| | | List<MdcPlanClose> mdcPlanCloses = this.baseMapper.selectList(queryWrapper); |
| | | // 导出文件名称 |
| | | mv.addObject(NormalExcelConstants.FILE_NAME, title + "列表"); |
| | | mv.addObject(NormalExcelConstants.CLASS, MdcPlanClose.class); |
| | | LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | mv.addObject(NormalExcelConstants.PARAMS, new ExportParams(title + "列表数据", "导出人:" + user.getRealname(), title)); |
| | | //update-end---author:wangshuai ---date:20211227 for:[JTC-116]导出人写死了------------ |
| | | mv.addObject(NormalExcelConstants.DATA_LIST, mdcPlanCloses); |
| | | return mv; |
| | | } |
| | | |
| | | @Override |
| | | public BigDecimal findPlanTimeDuration(BigDecimal actualWorkDayCount, String planCloseType) { |
| | | BigDecimal result = new BigDecimal("0"); |
| | | List<MdcPlanClose> mdcPlanCloses = this.baseMapper.selectList(new LambdaQueryWrapper<MdcPlanClose>().in(MdcPlanClose::getPlanCloseType, Arrays.asList(planCloseType.split(",")))); |
| | | if (mdcPlanCloses != null && !mdcPlanCloses.isEmpty()) { |
| | | for (MdcPlanClose mdcPlanClose : mdcPlanCloses) { |
| | | switch (mdcPlanClose.getPlanCloseTimeType()) { |
| | | case MdcConstant.DAY: |
| | | result = result.add(actualWorkDayCount.multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()))); |
| | | break; |
| | | case MdcConstant.WEEK: |
| | | result = result.add(new BigDecimal("4").multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()))); |
| | | break; |
| | | case MdcConstant.MONTH: |
| | | result = result.add(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())); |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | // List<MdcPlanClose> mdcPlanCloses = this.baseMapper.selectList(new LambdaQueryWrapper<MdcPlanClose>().in(MdcPlanClose::getPlanCloseType, Arrays.asList(planCloseType.split(",")))); |
| | | // if (mdcPlanCloses != null && !mdcPlanCloses.isEmpty()) { |
| | | // for (MdcPlanClose mdcPlanClose : mdcPlanCloses) { |
| | | // switch (mdcPlanClose.getPlanCloseTimeType()) { |
| | | // case MdcConstant.DAY: |
| | | // result = result.add(actualWorkDayCount.multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()))); |
| | | // break; |
| | | // case MdcConstant.WEEK: |
| | | // result = result.add(new BigDecimal("4").multiply(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong()))); |
| | | // break; |
| | | // case MdcConstant.MONTH: |
| | | // result = result.add(new BigDecimal(mdcPlanClose.getPlanCloseTimeLong())); |
| | | // break; |
| | | // default: |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | return result; |
| | | } |
| | | |
| | | } |