|
@@ -1,15 +1,16 @@
|
|
|
package com.jeesite.modules.mes.web;
|
|
package com.jeesite.modules.mes.web;
|
|
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
-
|
|
|
|
|
import com.jeesite.common.collect.ListUtils;
|
|
import com.jeesite.common.collect.ListUtils;
|
|
|
|
|
+import com.jeesite.common.config.Global;
|
|
|
|
|
+import com.jeesite.common.entity.Page;
|
|
|
|
|
+import com.jeesite.common.lang.DateUtils;
|
|
|
import com.jeesite.common.lang.StringUtils;
|
|
import com.jeesite.common.lang.StringUtils;
|
|
|
|
|
+import com.jeesite.common.web.BaseController;
|
|
|
import com.jeesite.modules.mes.entity.MesLineProcess;
|
|
import com.jeesite.modules.mes.entity.MesLineProcess;
|
|
|
|
|
+import com.jeesite.modules.mes.entity.MesProductGlueDuration;
|
|
|
import com.jeesite.modules.mes.service.MesLineProcessService;
|
|
import com.jeesite.modules.mes.service.MesLineProcessService;
|
|
|
|
|
+import com.jeesite.modules.mes.service.MesLogService;
|
|
|
|
|
+import com.jeesite.modules.mes.service.MesProductGlueDurationService;
|
|
|
import com.jeesite.modules.mes.util.CommonUitl;
|
|
import com.jeesite.modules.mes.util.CommonUitl;
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,11 +23,12 @@ import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
|
|
-import com.jeesite.common.config.Global;
|
|
|
|
|
-import com.jeesite.common.entity.Page;
|
|
|
|
|
-import com.jeesite.common.web.BaseController;
|
|
|
|
|
-import com.jeesite.modules.mes.entity.MesProductGlueDuration;
|
|
|
|
|
-import com.jeesite.modules.mes.service.MesProductGlueDurationService;
|
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 涂胶加工时长Controller
|
|
* 涂胶加工时长Controller
|
|
@@ -43,6 +45,9 @@ public class MesProductGlueDurationController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private MesLineProcessService mesLineProcessService;
|
|
private MesLineProcessService mesLineProcessService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private MesLogService mesLogService;
|
|
|
|
|
+
|
|
|
@ModelAttribute
|
|
@ModelAttribute
|
|
|
public MesProductGlueDuration get(String id, boolean isNewRecord) {
|
|
public MesProductGlueDuration get(String id, boolean isNewRecord) {
|
|
|
return mesProductGlueDurationService.get(id, isNewRecord);
|
|
return mesProductGlueDurationService.get(id, isNewRecord);
|
|
@@ -90,6 +95,81 @@ public class MesProductGlueDurationController extends BaseController {
|
|
|
mesProductGlueDurationService.delete(mesProductGlueDuration);
|
|
mesProductGlueDurationService.delete(mesProductGlueDuration);
|
|
|
return renderResult(Global.TRUE, text("删除涂胶加工时长成功!"));
|
|
return renderResult(Global.TRUE, text("删除涂胶加工时长成功!"));
|
|
|
}
|
|
}
|
|
|
|
|
+ @RequestMapping(value = "pcProcessTime")
|
|
|
|
|
+ @ResponseBody
|
|
|
|
|
+ public String pcProcessTime(HttpServletRequest request) {
|
|
|
|
|
+ if (request == null) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("请求错误"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (request != null) {
|
|
|
|
|
+ mesLogService.apisave(request);
|
|
|
|
|
+
|
|
|
|
|
+ String oprno = trimParam(request, "oprno");
|
|
|
|
|
+ String lineSn = trimParam(request, "lineSn");
|
|
|
|
|
+ String sn = trimParam(request, "sn");
|
|
|
|
|
+ String ucode = trimParam(request, "ucode");
|
|
|
|
|
+ String startTimeStr = trimParam(request, "startTime");
|
|
|
|
|
+ String endTimeStr = trimParam(request, "endTime");
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isBlank(oprno) || StringUtils.isBlank(lineSn) || StringUtils.isBlank(sn)
|
|
|
|
|
+ || StringUtils.isBlank(startTimeStr) || StringUtils.isBlank(endTimeStr)) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("参数错误"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Date startTime = DateUtils.parseDate(startTimeStr);
|
|
|
|
|
+ Date endTime = DateUtils.parseDate(endTimeStr);
|
|
|
|
|
+ if (startTime == null || endTime == null) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("涂胶开始时间获取失败"));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (endTime.before(startTime)) {
|
|
|
|
|
+ return renderResult(Global.FALSE, text("涂胶结束时间失败"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ long durationSeconds = (endTime.getTime() - startTime.getTime()) / 1000;
|
|
|
|
|
+ String glueDuration = formatDuration(durationSeconds);
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ MesProductGlueDuration mesProductGlueDuration = new MesProductGlueDuration();
|
|
|
|
|
+ mesProductGlueDuration.setOprno(oprno);
|
|
|
|
|
+ mesProductGlueDuration.setLineSn(lineSn);
|
|
|
|
|
+ mesProductGlueDuration.setSn(sn);
|
|
|
|
|
+ mesProductGlueDuration.setGlueDuration(glueDuration);
|
|
|
|
|
+ mesProductGlueDuration.setRemarks(buildRemarks(ucode, startTimeStr, endTimeStr));
|
|
|
|
|
+ mesProductGlueDurationService.save(mesProductGlueDuration);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, Object> data = new HashMap<>();
|
|
|
|
|
+ data.put("id", mesProductGlueDuration.getId());
|
|
|
|
|
+ data.put("glueDuration", glueDuration);
|
|
|
|
|
+ return renderResult(Global.TRUE, text("上传数据成功"), data);
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ logger.error("后台保存失败", e);
|
|
|
|
|
+ return renderResult(Global.FALSE, text("failed: "
|
|
|
|
|
+ + (StringUtils.isNotBlank(e.getMessage()) ? e.getMessage() : "system error")));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return renderResult(Global.TRUE, text("删除涂胶加工时长成功!"));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String trimParam(HttpServletRequest request, String name) {
|
|
|
|
|
+ return StringUtils.trim(request.getParameter(name));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String formatDuration(long seconds) {
|
|
|
|
|
+ long hours = seconds / 3600;
|
|
|
|
|
+ long minutes = (seconds % 3600) / 60;
|
|
|
|
|
+ long remainingSeconds = seconds % 60;
|
|
|
|
|
+ return String.format("%02d:%02d:%02d", hours, minutes, remainingSeconds);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private String buildRemarks(String ucode, String startTime, String endTime) {
|
|
|
|
|
+ StringBuilder remarks = new StringBuilder();
|
|
|
|
|
+ if (StringUtils.isNotBlank(ucode)) {
|
|
|
|
|
+ remarks.append("ucode=").append(ucode).append("; ");
|
|
|
|
|
+ }
|
|
|
|
|
+ remarks.append("startTime=").append(startTime).append("; endTime=").append(endTime);
|
|
|
|
|
+ return remarks.toString();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
private void fillOprnoTitle(List<MesProductGlueDuration> list) {
|
|
private void fillOprnoTitle(List<MesProductGlueDuration> list) {
|
|
|
if (ListUtils.isEmpty(list)) {
|
|
if (ListUtils.isEmpty(list)) {
|