Ver Fonte

大屏优化

liuwei há 2 meses atrás
pai
commit
cf61e798ba

+ 14 - 0
src/main/java/com/jeesite/modules/mes/entity/MesProductScreen.java

@@ -3,6 +3,7 @@ package com.jeesite.modules.mes.entity;
 import com.jeesite.common.entity.DataEntity;
 import com.jeesite.common.mybatis.annotation.Column;
 import com.jeesite.common.mybatis.annotation.Table;
+import com.jeesite.common.mybatis.mapper.query.QueryType;
 
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.Size;
@@ -15,6 +16,7 @@ import javax.validation.constraints.Size;
  */
 @Table(name="mes_product_screen", alias="a", label="大屏展示配置信息", columns={
 		@Column(name="id", attrName="id", label="id", isPK=true),
+		@Column(name="screen_type", attrName="screenType", label="大屏类型", comment="MP毛坯 JJ机加 BP半成品", queryType=QueryType.EQ),
 		@Column(name="people_num", attrName="peopleNum", label="生产人数"),
 		@Column(name="machine_num", attrName="machineNum", label="设备数量"),
 		@Column(name="plan_output", attrName="planOutput", label="计划产量"),
@@ -27,6 +29,8 @@ import javax.validation.constraints.Size;
 public class MesProductScreen extends DataEntity<MesProductScreen> {
 
 	private static final long serialVersionUID = 1L;
+	/** MP毛坯 / JJ机加 / BP半成品 */
+	private String screenType;
 	private String peopleNum;
 	private String machineNum;
 	private String planOutput;
@@ -39,6 +43,16 @@ public class MesProductScreen extends DataEntity<MesProductScreen> {
 		super(id);
 	}
 
+	@NotBlank(message="大屏类型不能为空")
+	@Size(min=0, max=32, message="大屏类型长度不能超过 32 个字符")
+	public String getScreenType() {
+		return screenType;
+	}
+
+	public void setScreenType(String screenType) {
+		this.screenType = screenType;
+	}
+
 	@NotBlank(message="生产人数不能为空")
 	@Size(min=0, max=255, message="生产人数长度不能超过 255 个字符")
 	public String getPeopleNum() {

+ 43 - 1
src/main/java/com/jeesite/modules/mes/service/MesProductScreenService.java

@@ -36,6 +36,9 @@ public class MesProductScreenService extends CrudService<MesProductScreenDao, Me
 	@Override
 	@Transactional
 	public void save(MesProductScreen mesProductScreen) {
+		if (mesProductScreen != null) {
+			mesProductScreen.setScreenType(normalizeScreenType(mesProductScreen.getScreenType()));
+		}
 		super.save(mesProductScreen);
 	}
 
@@ -46,7 +49,46 @@ public class MesProductScreenService extends CrudService<MesProductScreenDao, Me
 	}
 
 	public MesProductScreen getLatest() {
+		return getLatestByScreenType(null);
+	}
+
+	/**
+	 * 按大屏类型取最新一条配置。screenType 为空时取全局最新(兼容旧调用)。
+	 * MP毛坯 / JJ机加 / BP半成品
+	 */
+	public MesProductScreen getLatestByScreenType(String screenType) {
+		String code = normalizeScreenType(screenType);
 		List<MesProductScreen> list = findList(new MesProductScreen());
-		return ObjectUtils.isEmpty(list) ? null : list.get(0);
+		if (ObjectUtils.isEmpty(list)) {
+			return null;
+		}
+		if (code == null || code.isEmpty()) {
+			return list.get(0);
+		}
+		for (MesProductScreen item : list) {
+			if (item == null) {
+				continue;
+			}
+			if (code.equals(normalizeScreenType(item.getScreenType()))) {
+				return item;
+			}
+		}
+		return null;
+	}
+
+	/** JeeSite select 可能提交成 JJ=机加大屏,统一成 JJ / MP / BP */
+	public static String normalizeScreenType(String screenType) {
+		if (screenType == null) {
+			return "";
+		}
+		String s = screenType.trim();
+		if (s.isEmpty()) {
+			return "";
+		}
+		int eq = s.indexOf('=');
+		if (eq > 0) {
+			s = s.substring(0, eq).trim();
+		}
+		return s.toUpperCase();
 	}
 }

+ 16 - 2
src/main/java/com/jeesite/modules/mes/web/MesProductScreenController.java

@@ -73,6 +73,7 @@ public class MesProductScreenController extends BaseController {
 	@RequestMapping(value = {"list", ""})
 	public String list(MesProductScreen mesProductScreen, Model model) {
 		model.addAttribute("mesProductScreen", mesProductScreen);
+		model.addAttribute("screenTypeMap", buildScreenTypeMap());
 		return "modules/mes/mesProductScreenList";
 	}
 
@@ -89,9 +90,18 @@ public class MesProductScreenController extends BaseController {
 	@RequestMapping(value = "form")
 	public String form(MesProductScreen mesProductScreen, Model model) {
 		model.addAttribute("mesProductScreen", mesProductScreen);
+		model.addAttribute("screenTypeMap", buildScreenTypeMap());
 		return "modules/mes/mesProductScreenForm";
 	}
 
+	private static Map<String, String> buildScreenTypeMap() {
+		Map<String, String> map = new java.util.LinkedHashMap<>();
+		map.put("MP", "毛坯大屏");
+		map.put("JJ", "机加大屏");
+		map.put("BP", "半成品大屏");
+		return map;
+	}
+
 	@RequiresPermissions("mes:mesProductScreen:edit")
 	@PostMapping(value = "save")
 	@ResponseBody
@@ -110,10 +120,14 @@ public class MesProductScreenController extends BaseController {
 
 	@RequestMapping(value = "latestConfig")
 	@ResponseBody
-	public CommonResp<Map<String, Object>> latestConfig() {
+	public CommonResp<Map<String, Object>> latestConfig(HttpServletRequest request) {
 		CommonResp<Map<String, Object>> resp = new CommonResp<>();
-		MesProductScreen latest = mesProductScreenService.getLatest();
+		String screenType = StringUtils.trimToEmpty(request.getParameter("screenType"));
+		MesProductScreen latest = StringUtils.isNotBlank(screenType)
+				? mesProductScreenService.getLatestByScreenType(screenType)
+				: mesProductScreenService.getLatest();
 		Map<String, Object> data = new HashMap<>();
+		data.put("screenType", latest == null ? screenType : latest.getScreenType());
 		data.put("peopleNums", parseIntSafe(latest == null ? null : latest.getPeopleNum()));
 		data.put("deviceNums", parseIntSafe(latest == null ? null : latest.getMachineNum()));
 		data.put("planNums", parseIntSafe(latest == null ? null : latest.getPlanOutput()));

+ 20 - 0
src/main/resources/views/modules/mes/mesProductScreenForm.html

@@ -17,6 +17,20 @@
 					<div class="col-xs-6">
 						<div class="form-group">
 							<label class="control-label col-sm-4" title="">
+								<span class="required ">*</span> ${text('大屏类型')}:<i class="fa icon-question hide"></i></label>
+							<div class="col-sm-8">
+								<select name="screenType" id="screenType" class="form-control required">
+									<option value="">${text('-- 请选择 --')}</option>
+									<option value="MP">毛坯大屏</option>
+									<option value="JJ">机加大屏</option>
+									<option value="BP">半成品大屏</option>
+								</select>
+							</div>
+						</div>
+					</div>
+					<div class="col-xs-6">
+						<div class="form-group">
+							<label class="control-label col-sm-4" title="">
 								<span class="required ">*</span> ${text('生产人数')}:<i class="fa icon-question hide"></i></label>
 							<div class="col-sm-8">
 								<#form:input path="peopleNum" maxlength="255" class="form-control required digits"/>
@@ -70,4 +84,10 @@ $("#inputForm").validate({
 		}, "json");
     }
 });
+(function(){
+	var st = "${mesProductScreen.screenType!}";
+	var eq = st.indexOf('=');
+	if (eq > 0) st = st.substring(0, eq);
+	$("#screenType").val(st);
+})();
 </script>

+ 20 - 0
src/main/resources/views/modules/mes/mesProductScreenList.html

@@ -18,6 +18,17 @@
 			<#form:form id="searchForm" model="${mesProductScreen}" action="${ctx}/mes/mesProductScreen/listData" method="post" class="form-inline hide"
 					data-page-no="${parameter.pageNo}" data-page-size="${parameter.pageSize}" data-order-by="${parameter.orderBy}">
 				<div class="form-group">
+					<label class="control-label">${text('大屏类型')}:</label>
+					<div class="control-inline">
+						<select name="screenType" class="form-control width-120">
+							<option value="">${text('全部')}</option>
+							<option value="MP">毛坯大屏</option>
+							<option value="JJ">机加大屏</option>
+							<option value="BP">半成品大屏</option>
+						</select>
+					</div>
+				</div>
+				<div class="form-group">
 					<label class="control-label">${text('生产人数')}:</label>
 					<div class="control-inline">
 						<#form:input path="peopleNum" maxlength="255" class="form-control width-120"/>
@@ -50,6 +61,15 @@
 $('#dataGrid').dataGrid({
 	searchForm: $("#searchForm"),
 	columnModel: [
+		{header:'${text("大屏类型")}', name:'screenType', index:'a.screen_type', width:120, align:"center", formatter: function(val){
+			var code = String(val || '');
+			var eq = code.indexOf('=');
+			if (eq > 0) code = code.substring(0, eq);
+			if (code === 'MP') return '毛坯大屏';
+			if (code === 'JJ') return '机加大屏';
+			if (code === 'BP') return '半成品大屏';
+			return val || '';
+		}},
 		{header:'${text("生产人数")}', name:'peopleNum', index:'a.people_num', width:150, align:"center"},
 		{header:'${text("设备数量")}', name:'machineNum', index:'a.machine_num', width:150, align:"center"},
 		{header:'${text("计划产量")}', name:'planOutput', index:'a.plan_output', width:150, align:"center"},

+ 2 - 2
src/main/resources/views/modules/mes/mesScreen4.html

@@ -329,8 +329,8 @@
 				<tr>
 					<th style="width:160px">工位</th>
 					<th style="width:300px">工位名称</th>
-					<th>实际产能</th>
-					<th>当班产能</th>
+					<th>当天产量</th>
+					<th>当班产量</th>
 					<th>上班产量</th>
 				</tr>
 				</thead>

+ 2 - 2
src/main/resources/views/modules/mes/mesScreen5.html

@@ -347,8 +347,8 @@
 				<tr>
 					<th style="width:160px">工位</th>
 					<th style="width:300px">工位名称</th>
-					<th>实际产能</th>
-					<th>当班产能</th>
+					<th>当天产量</th>
+					<th>当班产量</th>
 					<th>上班产量</th>
 				</tr>
 				</thead>

+ 2 - 2
src/main/resources/views/modules/mes/mesScreen6.html

@@ -329,8 +329,8 @@
 					<th style="width:200px">工位名称</th>
 					<th>计划产能</th>
 					<th>小时产能</th>
-					<th>实际产能</th>
-					<th>当班产能(12小时内)</th>
+					<th>当天产量</th>
+					<th>当班产量(12小时内)</th>
 					<th>上班产量</th>
 				</tr>
 				</thead>