public String repairApply(String orderId, String repairId, String lastTime) { LoginUser loginUser = SecurityUtils.getLoginUser(); Map<String, Object> map = repairResumeMapper.selectAllById(repairId); if(!"1".equals(map.get("repair_state"))) { return "申请已被处理"; } if(orderMapper.selectExclusive(orderId, lastTime) == 0) { return "订单发生变更,请刷新页面重新操作"; } Map<String, Object> orderInfo = orderMapper.selectOrderById(Long.parseLong(orderId)); String type = orderInfo.get("order_no_type").toString(); String fType = orderInfo.get("fabrics").toString(); String genNo = ""; if("SU".equals(type)) { genNo = "SU0"; } else { genNo = type + ("3".equals(fType) ? "6" : "8"); } String no = genNoService.genOrderNo(genNo); if(no == null) { return "订单编号超出最大数量限制"; } String day = DictUtils.getDictLabel("delivery_time", fType); Date d = DateUtils.addDays(DateUtils.getNowDate() , Integer.parseInt(day)); Date deTime = DateUtils.parseDate(DateUtils.dateTime(d)); OrderInfo param = new OrderInfo(); param.setOrderNo(no); param.setCreateBy(loginUser.getUsername()); param.setId(orderId); param.setDeliveryTime(deTime); repairResumeMapper.insertRepairOrder(param); OrderFileAsso of = new OrderFileAsso(); of.setOrderId(Long.parseLong(param.getUuid())); of.setFileId(Long.parseLong(map.get("file_id").toString())); of.setFileState("3"); of.setOrderState("2"); fileMapper.insertOrderFileAsso(of); OrderInfo oo = new OrderInfo(); oo.setUuid(orderId); oo.setRepairState("2"); oo.setUpdateBy(loginUser.getUsername()); orderMapper.updateOrder(oo); RepairResume repairResume = new RepairResume(); repairResume.setId(Long.parseLong(repairId)); repairResume.setRepairState("3"); repairResume.setUpdateBy(loginUser.getUsername()); repairResumeMapper.update(repairResume); return ""; }翻译这段代码
时间: 2024-04-27 19:23:57 浏览: 135
这段代码是一个Java方法,名为repairApply,接收三个参数:orderId,repairId和lastTime,返回一个字符串。首先,该方法通过SecurityUtils.getLoginUser()获取当前登录用户,然后通过repairResumeMapper.selectAllById(repairId)获取一个Map对象map。如果map中的"repair_state"不等于1,说明该申请已经被处理过,直接返回"申请已被处理"。接下来,如果orderMapper.selectExclusive(orderId, lastTime)返回0,说明订单发生变更,需要重新操作,返回"订单发生变更,请刷新页面重新操作"。然后,通过orderMapper.selectOrderById(Long.parseLong(orderId))获取一个Map对象orderInfo,并从中获取"order_no_type"和"fabrics"属性,根据这两个属性拼接订单编号。如果没有超出最大数量限制,就将该订单编号赋值给no。然后,根据"fabrics"属性获取交货时间,并计算出交货日期d,再将d转换为日期类型deTime。接下来,将订单编号、创建人、交货时间和ID插入repairResumeMapper。然后,创建一个OrderFileAsso对象of,并将该订单ID、文件ID、文件状态和订单状态插入fileMapper。接着,创建一个OrderInfo对象oo,并将该订单ID、维修状态和更新人插入orderMapper。最后,创建一个RepairResume对象repairResume,并将该维修申请ID、维修状态和更新人插入repairResumeMapper。最终,返回一个空字符串。
阅读全文