|
|
|
|
@ -2,12 +2,14 @@ package com.ruoyi.web.controller.tyre;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
|
import com.ruoyi.common.annotation.RepeatSubmit;
|
|
|
|
|
import com.ruoyi.common.config.RuoYiConfig;
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
|
|
|
|
import com.ruoyi.system.domain.*;
|
|
|
|
|
@ -22,6 +24,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
@ -188,7 +191,21 @@ public class BizMaintenanceOrderController extends BaseController {
|
|
|
|
|
*/
|
|
|
|
|
@PostMapping("/PDAAddMaintenanceOrder")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public AjaxResult PDAAddMaintenanceOrder(@RequestBody BizMaintenanceOrder bizMaintenanceOrder) {
|
|
|
|
|
@RepeatSubmit
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public synchronized AjaxResult PDAAddMaintenanceOrder(@RequestBody BizMaintenanceOrder bizMaintenanceOrder) {
|
|
|
|
|
if (bizMaintenanceOrder == null) {
|
|
|
|
|
return error("参数不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(bizMaintenanceOrder.getPlateNumber())) {
|
|
|
|
|
return error("车牌号不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isEmpty(bizMaintenanceOrder.getTypeCode())) {
|
|
|
|
|
return error("维保类型不能为空");
|
|
|
|
|
}
|
|
|
|
|
if (bizMaintenanceOrderService.countSameDayMaintenanceOrder(bizMaintenanceOrder) > 0) {
|
|
|
|
|
return error("同一车辆同一维保类型当天只能生成一次工单");
|
|
|
|
|
}
|
|
|
|
|
String orderNo = orderNoCreate();
|
|
|
|
|
bizMaintenanceOrder.setOrderNo(orderNo);
|
|
|
|
|
return toAjax(bizMaintenanceOrderService.insertBizMaintenanceOrder(bizMaintenanceOrder));
|
|
|
|
|
@ -290,10 +307,12 @@ public class BizMaintenanceOrderController extends BaseController {
|
|
|
|
|
|
|
|
|
|
private String orderNoCreate() {
|
|
|
|
|
// 查询当天的工单号(返回的是当天最新的一条记录)
|
|
|
|
|
BizMaintenanceOrder bizMaintenanceOrder = bizMaintenanceOrderService.selectBizMaintenanceOrderTD();
|
|
|
|
|
BizMaintenanceOrder query = new BizMaintenanceOrder();
|
|
|
|
|
fillTodayRange(query);
|
|
|
|
|
BizMaintenanceOrder bizMaintenanceOrder = bizMaintenanceOrderService.selectBizMaintenanceOrderTD(query);
|
|
|
|
|
|
|
|
|
|
String orderNo;
|
|
|
|
|
String today = new java.text.SimpleDateFormat("yyyyMMdd").format(new java.util.Date());
|
|
|
|
|
String today = DateUtils.dateTime();
|
|
|
|
|
|
|
|
|
|
if (bizMaintenanceOrder == null) {
|
|
|
|
|
// 当天没有工单,从001开始
|
|
|
|
|
@ -312,4 +331,11 @@ public class BizMaintenanceOrderController extends BaseController {
|
|
|
|
|
}
|
|
|
|
|
return orderNo;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void fillTodayRange(BizMaintenanceOrder bizMaintenanceOrder) {
|
|
|
|
|
LocalDate today = LocalDate.now();
|
|
|
|
|
// 使用 Java 计算当天半开区间,避免在 Mapper 中写 MySQL/SQL Server 不兼容的日期函数。
|
|
|
|
|
bizMaintenanceOrder.getParams().put("beginTime", DateUtils.toDate(today));
|
|
|
|
|
bizMaintenanceOrder.getParams().put("endTime", DateUtils.toDate(today.plusDays(1)));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|