| | |
| | | package org.jeecg.modules.eam.controller; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.eam.entity.*; |
| | | import org.jeecg.modules.eam.service.*; |
| | | import org.jeecg.modules.eam.vo.EquipmentAvailabilityVo; |
| | | import org.jeecgframework.poi.excel.ExcelImportUtil; |
| | | import org.jeecgframework.poi.excel.def.NormalExcelConstants; |
| | | import org.jeecgframework.poi.excel.entity.ExportParams; |
| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.text.ParseException; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | @PutMapping(value = "/report") |
| | | @Transactional(rollbackFor = {Exception.class}) |
| | | public Result<?> orderReport(@RequestBody RepairOrder repairOrder){ |
| | | String id = repairOrder.getId(); |
| | | List<RepairOrderActualWorkHours> hoursList = repairOrderActualWorkHoursService.list(new QueryWrapper<RepairOrderActualWorkHours>().eq("repair_order_id",id).eq("del_flag",0)); |
| | | List<RepairOrderActualWorkHours> mainStuff = repairOrderActualWorkHoursService.list(new QueryWrapper<RepairOrderActualWorkHours>().eq("repair_order_id",id).eq("del_flag",0).eq("principal_contractor","1")); |
| | | if(hoursList.size()<2){ |
| | | return Result.error("操作失败,请至少添加两个承修人"); |
| | | } |
| | | if(mainStuff.size()!=1){ |
| | | return Result.error("操作失败,请添加主承修人,有且只有一个"); |
| | | } |
| | | if(StringUtils.isNotBlank(repairOrder.getProjectMaintenanceOrderId())){ |
| | | //判断项目性维修子表状态 |
| | | ProjectMaintenanceOrderDetail projectMaintenanceOrderDetail = projectMaintenanceOrderDetailService.getById(repairOrder.getProjectMaintenanceOrderId()); |
| | |
| | | repairOrder.setStatus("4"); |
| | | repairOrder.setActualEndTime(now); |
| | | repairOrder.setActualHour(hours); |
| | | repairOrder.setRecipientUserId(user.getId()); |
| | | repairOrder.setRecipientUserId(mainStuff.get(0).getUserId()); |
| | | repairOrderService.updateById(repairOrder); |
| | | if(StringUtils.isNotBlank(repairOrder.getEquipmentId())){ |
| | | Equipment equipment = equipmentService.getById(repairOrder.getEquipmentId()); |
| | | equipment.setEquipmentStatus("4"); |
| | | equipmentService.updateById(equipment); |
| | | } |
| | | return Result.OK("报工成功"); |
| | | } |
| | | /** |
| | |
| | | repairOrder.setRepairOrderUda2(new Date()); |
| | | repairOrder.setRepairOrderUda1("needSpare"); |
| | | repairOrderService.updateById(repairOrder); |
| | | if(StringUtils.isNotBlank(repairOrder.getEquipmentId())){ |
| | | Equipment equipment = equipmentService.getById(repairOrder.getEquipmentId()); |
| | | equipment.setEquipmentStatus("8"); |
| | | equipmentService.updateById(equipment); |
| | | } |
| | | return Result.OK("操作成功"); |
| | | } |
| | | /** |
| | |
| | | repairOrder.setRepairOrderUda1("normal"); |
| | | repairOrder.setSpareTime(hours); |
| | | repairOrderService.updateById(repairOrder); |
| | | if(StringUtils.isNotBlank(repairOrder.getEquipmentId())){ |
| | | Equipment equipment = equipmentService.getById(repairOrder.getEquipmentId()); |
| | | equipment.setEquipmentStatus("7"); |
| | | equipmentService.updateById(equipment); |
| | | } |
| | | return Result.OK("操作成功"); |
| | | } |
| | | /** |
| | |
| | | repairOrder.setRepairOrderUda4(new Date()); |
| | | repairOrder.setRepairOrderUda1("needPart"); |
| | | repairOrderService.updateById(repairOrder); |
| | | if(StringUtils.isNotBlank(repairOrder.getEquipmentId())){ |
| | | Equipment equipment = equipmentService.getById(repairOrder.getEquipmentId()); |
| | | equipment.setEquipmentStatus("9"); |
| | | equipmentService.updateById(equipment); |
| | | } |
| | | return Result.OK("操作成功"); |
| | | } |
| | | /** |
| | |
| | | repairOrder.setRepairOrderUda1("normal"); |
| | | repairOrder.setPartTime(hours); |
| | | repairOrderService.updateById(repairOrder); |
| | | if(StringUtils.isNotBlank(repairOrder.getEquipmentId())){ |
| | | Equipment equipment = equipmentService.getById(repairOrder.getEquipmentId()); |
| | | equipment.setEquipmentStatus("7"); |
| | | equipmentService.updateById(equipment); |
| | | } |
| | | return Result.OK("操作成功"); |
| | | } |
| | | |
| | | /** |
| | | * 设备完好率 |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping("/equipmentAvailability") |
| | | public JSONObject equipmentAvailability(@RequestParam Map<String, String> query) throws ParseException { |
| | | List<EquipmentAvailabilityVo> list = repairOrderService.equipmentAvailability(query); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("data",list); |
| | | return jsonObject; |
| | | } |
| | | |
| | | /** |
| | | * 设备可开动率 |
| | | * |
| | | * @return |
| | | */ |
| | | @GetMapping("/getStartRate") |
| | | public JSONObject getStartRate(@RequestParam Map<String, String> query) throws ParseException { |
| | | List<EquipmentAvailabilityVo> list = repairOrderService.getStartRate(query); |
| | | JSONObject jsonObject = new JSONObject(); |
| | | jsonObject.put("data",list); |
| | | return jsonObject; |
| | | } |
| | | } |