| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.fasterxml.jackson.core.JsonProcessingException; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.flowable.engine.TaskService; |
| | | import org.flowable.task.api.Task; |
| | | import org.jeecg.common.api.vo.FileUploadResult; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.constant.DataBaseConstant; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.constant.InspectionStatus; |
| | | import org.jeecg.modules.eam.entity.EamEquipment; |
| | | import org.jeecg.modules.eam.entity.EamInspectionOrder; |
| | | import org.jeecg.modules.eam.entity.EamInspectionOrderDetail; |
| | | import org.jeecg.modules.eam.entity.EamWeekMaintenanceOrder; |
| | | import org.jeecg.modules.eam.mapper.EamInspectionOrderMapper; |
| | | import org.jeecg.modules.eam.request.EamInspectionOrderQuery; |
| | | import org.jeecg.modules.eam.request.EamInspectionOrderRequest; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEamInspectionOrderDetailService; |
| | |
| | | */ |
| | | @Service("IEamInspectionOrderService") |
| | | public class EamInspectionOrderServiceImpl extends ServiceImpl<EamInspectionOrderMapper, EamInspectionOrder> implements IEamInspectionOrderService, FlowCallBackServiceI { |
| | | |
| | | @Resource |
| | | private EamInspectionOrderMapper eamInspectionOrderMapper; |
| | | @Autowired |
| | | private IEamInspectionOrderDetailService eamInspectionOrderDetailService; |
| | | @Resource |
| | |
| | | private IMdcUserProductionService mdcUserProductionService; |
| | | @Autowired |
| | | private IEamReportRepairService eamReportRepairService; |
| | | |
| | | @Override |
| | | public IPage<EamInspectionOrder> queryPageList(Page<EamInspectionOrder> page, EamInspectionOrderQuery query) { |
| | | QueryWrapper<EamInspectionOrder> queryWrapper = new QueryWrapper<>(); |
| | | //用户数据权限 |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | return page; |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //选择了设备,根据设备id过滤设备 |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("e.equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据车间过滤设备 |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=e.org_id ", sysUser.getId()); |
| | | } |
| | | //查询条件过滤 |
| | | if (query != null) { |
| | | if (StringUtils.isNotBlank(query.getEquipmentId())) { |
| | | queryWrapper.eq("wmo.equipment_id", query.getEquipmentId()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getOrderNum())) { |
| | | queryWrapper.like("wmo.order_num", query.getOrderNum()); |
| | | } |
| | | if (StringUtils.isNotBlank(query.getInspectionStatus())) { |
| | | queryWrapper.eq("wmo.inspection_status", query.getInspectionStatus()); |
| | | } |
| | | if (query.getInspectionDateBegin() != null && query.getInspectionDateEnd() != null) { |
| | | queryWrapper.between("wmo.inspection_date", query.getInspectionDateBegin(), query.getInspectionDateEnd()); |
| | | } |
| | | //排序 |
| | | if (StringUtils.isNotBlank(query.getColumn()) && StringUtils.isNotBlank(query.getOrder())) { |
| | | String column = query.getColumn(); |
| | | if (column.endsWith(CommonConstant.DICT_TEXT_SUFFIX)) { |
| | | column = column.substring(0, column.lastIndexOf(CommonConstant.DICT_TEXT_SUFFIX)); |
| | | } |
| | | if (DataBaseConstant.SQL_ASC.equalsIgnoreCase(query.getOrder())) { |
| | | queryWrapper.orderByAsc("wmo." + oConvertUtils.camelToUnderline(column)); |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo." + oConvertUtils.camelToUnderline(column)); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo.create_time"); |
| | | } |
| | | } else { |
| | | queryWrapper.orderByDesc("wmo.create_time"); |
| | | } |
| | | |
| | | return eamInspectionOrderMapper.queryPageList(page, queryWrapper); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | private boolean isValidRequest(EamInspectionOrderRequest request) { |
| | | return StrUtil.isNotBlank(request.getTaskId()) && StrUtil.isNotBlank(request.getDataId()); |
| | | } |
| | |
| | | } else { |
| | | // 班组长确认 |
| | | values.put("dataId", order.getId()); |
| | | values.put("organization", request.getDealSuggestion()); |
| | | values.put("comment", request.getDealSuggestion()); |
| | | values.put("confirmation", request.getDealType()); |
| | | request.setComment(request.getDealSuggestion()); |
| | | if ("2".equals(request.getDealType())) { |
| | | values.put("organization", request.getConfirmComment()); |
| | | values.put("comment", request.getConfirmComment()); |
| | | values.put("confirmation", request.getConfirmDealType()); |
| | | request.setComment(request.getConfirmComment()); |
| | | if ("2".equals(request.getConfirmDealType())) { |
| | | // 班组长驳回 |
| | | List<String> usernames = new ArrayList<>(); |
| | | usernames.add(order.getOperator()); |
| | |
| | | |
| | | private void updateOrderStatus(Result result, EamInspectionOrderRequest request, EamInspectionOrder order, LoginUser user) { |
| | | if (result.isSuccess()) { |
| | | if (InspectionStatus.UNDER_INSPECTION.name().equals(order.getInspectionStatus()) && StrUtil.isEmpty(request.getDealType())) { |
| | | if (InspectionStatus.UNDER_INSPECTION.name().equals(order.getInspectionStatus()) && StrUtil.isEmpty(request.getConfirmDealType())) { |
| | | // 点检完成 |
| | | order.setInspectionStatus(InspectionStatus.WAIT_CONFIRM.name()); |
| | | order.setOperateTime(new Date()); |
| | | eamInspectionOrderDetailService.remove(new QueryWrapper<EamInspectionOrderDetail>().eq("order_id", order.getId())); |
| | | eamInspectionOrderDetailService.saveBatch(request.getTableDetailList()); |
| | | } else if (InspectionStatus.WAIT_CONFIRM.name().equals(order.getInspectionStatus()) && StrUtil.isNotEmpty(request.getDealType())) { |
| | | } else if (InspectionStatus.WAIT_CONFIRM.name().equals(order.getInspectionStatus()) && StrUtil.isNotEmpty(request.getConfirmDealType())) { |
| | | // 班组长确认任务 |
| | | order.setInspectionStatus(InspectionStatus.COMPLETE.name()); |
| | | order.setConfirmUser(user.getUsername()); |
| | | order.setConfirmComment(request.getConfirmComment()); |
| | | order.setConfirmDealType(request.getConfirmDealType()); |
| | | order.setConfirmTime(new Date()); |
| | | } |
| | | } |