| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.api.dto.message.MessageDTO; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.aspect.annotation.AutoLog; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | | import org.jeecg.common.system.api.ISysBaseAPI; |
| | | import org.jeecg.common.system.base.controller.JeecgController; |
| | | import org.jeecg.common.system.query.QueryGenerator; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.eam.entity.Equipment; |
| | | import org.jeecg.modules.eam.entity.EquipmentReportRepair; |
| | | import org.jeecg.modules.eam.entity.FaultDescription; |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.service.IEquipmentReportRepairService; |
| | | import org.jeecg.modules.eam.service.IFaultDescriptionService; |
| | | import org.jeecg.modules.eam.entity.QuanlityConfirm; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | private IEquipmentReportRepairService equipmentReportRepairService; |
| | | @Autowired |
| | | private IEamEquipmentService equipmentService; |
| | | |
| | | @Autowired |
| | | private ISysBaseAPI sysBaseApi; |
| | | |
| | | @Autowired |
| | | private ISysUserService userService; |
| | | @Autowired |
| | | private IQuanlityConfirmService quanlityConfirmService; |
| | | @Autowired |
| | | @Lazy |
| | | private IFaultDescriptionService faultDescriptionService; |
| | | // @Autowired |
| | | // private IUploadRelaService uploadRelaService; |
| | | @Autowired |
| | | @Lazy |
| | | private IdentityService sysIdentityService; |
| | | |
| | | |
| | | /** |
| | | * 分页列表查询 |
| | |
| | | @AutoLog(value = "mom_eam_equipment_report_repair-添加") |
| | | @ApiOperation(value = "mom_eam_equipment_report_repair-添加", notes = "mom_eam_equipment_report_repair-添加") |
| | | @PostMapping(value = "/add") |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Result<String> add(@RequestBody EquipmentReportRepair equipmentReportRepair) { |
| | | LoginUser curUser= (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | equipmentReportRepair.setStatus("1"); |
| | | equipmentReportRepair.setSource("1"); |
| | | equipmentReportRepair.setIsCreateOrder(0); |
| | | equipmentReportRepairService.save(equipmentReportRepair); |
| | | String IS_PRODUCT_YES = "yes"; |
| | | if(IS_PRODUCT_YES.equals(equipmentReportRepair.getErrUda1())){ |
| | | String num = sysIdentityService.getNumByTypeAndLength("QuanlityConfirm",4); |
| | | QuanlityConfirm quanlityConfirm = new QuanlityConfirm(); |
| | | quanlityConfirm.setNum(num); |
| | | quanlityConfirm.setReportId(equipmentReportRepair.getId()); |
| | | String IS_PRODUCT_NO = "no"; |
| | | quanlityConfirm.setIsConfirm(IS_PRODUCT_NO); |
| | | quanlityConfirm.setBatchNo(equipmentReportRepair.getBatchNo()); |
| | | quanlityConfirm.setPartNumber(equipmentReportRepair.getPartNumber()); |
| | | quanlityConfirm.setQuantity(equipmentReportRepair.getQuantity()); |
| | | quanlityConfirm.setOperator(curUser.getId()); |
| | | quanlityConfirmService.save(quanlityConfirm); |
| | | } |
| | | Equipment equipment = equipmentService.getById(equipmentReportRepair.getEquipmentId()); |
| | | equipment.setEquipmentStatus("2"); |
| | | String teamId = equipment.getTeamId(); |
| | | if(ObjectUtils.isNotNull(teamId)){ |
| | | List<SysUser> sysUsers = userService.list(new QueryWrapper<SysUser>() |
| | | .eq("team_id",teamId) |
| | | .eq("del_flag",0)); |
| | | for(SysUser user:sysUsers){ |
| | | String msg = "统一编号为【"+equipment.getNum()+"】的设备需要维修,请移步至故障报修查看"; |
| | | MessageDTO messageDTO = new MessageDTO(); |
| | | messageDTO.setTitle("故障报修提醒"); |
| | | messageDTO.setContent(msg); |
| | | messageDTO.setCategory("故障报修提醒"); |
| | | messageDTO.setFromUser("故障报修提醒小助手"); |
| | | messageDTO.setToUser(user.getUsername()); |
| | | sysBaseApi.sendSysAnnouncement(messageDTO); |
| | | } |
| | | }else { |
| | | return Result.error("该设备尚未维护维修班组,请维护后再报修"); |
| | | } |
| | | //添加故障描述信息 |
| | | FaultDescription faultDescription = new FaultDescription(); |
| | | faultDescription.setFaultDetails(equipmentReportRepair.getFaultDescription()); |
| | | faultDescription.setFaultId(equipmentReportRepair.getId()); |
| | | faultDescription.setPhoto(equipmentReportRepair.getPhoto()); |
| | | faultDescriptionService.save(faultDescription); |
| | | equipmentService.updateById(equipment); |
| | | return Result.OK("添加成功!"); |
| | | } |
| | | |
| | |
| | | IPage<Map<String, Object>> equipmentReportRepairList = equipmentReportRepairService.getReportRepairList(pageNo, pageSize, params); |
| | | return Result.ok(equipmentReportRepairList); |
| | | } |
| | | |
| | | @PutMapping("/accept") |
| | | public Result<?> accept(@RequestBody EquipmentReportRepair equipmentReportRepair ){ |
| | | equipmentReportRepair.setStatus("5"); |
| | | equipmentReportRepair.setAcceptTime(new Date()); |
| | | equipmentReportRepairService.updateById(equipmentReportRepair); |
| | | String equipmentId = equipmentReportRepair.getEquipmentId(); |
| | | if(StringUtils.isNotBlank(equipmentId)){ |
| | | Equipment equipment = equipmentService.getById(equipmentId); |
| | | equipment.setEquipmentStatus("1"); |
| | | equipmentService.updateById(equipment); |
| | | } |
| | | return Result.OK("验收成功"); |
| | | } |
| | | } |