workinstruction.java

来自「工厂版本管理系统,STRUTS2框架,用于管理商品的版本,便于有效的控制版本」· Java 代码 · 共 171 行

JAVA
171
字号
package com.utstar.fcs.domain.workinstruction;

import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;

public class WorkInstruction {
	private Long id;

	private String partNumber;
	private String productName;
	private String productLine;

	private String suitableDepartment;
	private Set<Station> stations = new HashSet<Station>();
	private Map<String, WorkInstructionVersion> versions = new HashMap<String, WorkInstructionVersion>();

	public void addWorkInstructionVersion(
			WorkInstructionVersion workInstructionVersion) {
		VersionNumber vn = null;
		if (getLatestVersion() == null)
			vn = new VersionNumber();
		else
			vn = new VersionNumber(getLatestVersion().getVersion());

		workInstructionVersion.setVersion(vn.getNext());
		workInstructionVersion.setWorkInstruction(this);
		
		versions.put(workInstructionVersion.getVersion(),
				workInstructionVersion);
	}

	public Station addStation(Station station) {
		stations.add(station);
		station.setWorkInstruction(this);

		return station;
	}

	public static WorkInstruction getSample(List<StationType> stationTypeList) {
		WorkInstruction wi = new WorkInstruction();

		wi.setPartNumber("12345678901");
		wi.setProductName("ONU10000");
		wi.setProductLine("BBS");
		wi.setSuitableDepartment("SMT");

		// create some stations
		Random r = new Random();
		wi.addStation(Station.getSample(stationTypeList.get(r
				.nextInt(stationTypeList.size())), "插件"));
		wi.addStation(Station.getSample(stationTypeList.get(r
				.nextInt(stationTypeList.size())), "焊接"));
		wi.addStation(Station.getSample(stationTypeList.get(r
				.nextInt(stationTypeList.size())), "测试"));

		return wi;
	}

	public WorkInstructionVersion makeDefaultNewVersion() {
		WorkInstructionVersion wiv = new WorkInstructionVersion();

		wiv.setWorkInstruction(this);

		wiv.setApproval1("张三");
		wiv.setApproval2("李四");		
		wiv.setVersionComment("ok");
		
		
		
		VersionNumber vn = null;
		if (getLatestVersion() == null)
			vn = new VersionNumber();
		else
			vn = new VersionNumber(getLatestVersion().getVersion());

		wiv.setVersion(vn.getNext());

		// get latest station version
		Set stations = getStations();
		Iterator<Station> it = stations.iterator();
		while (it.hasNext()) {
			Station s = it.next();
			FlowChartItem fci = new FlowChartItem();
			fci.setEnabled(true);

			fci.setStationVersion(s.getLatestVersion());

			wiv.addFlowChartItem(fci);
		}
		
		return wiv;
	}
	
	public WorkInstructionVersion getLatestVersion() {

		if(versions.isEmpty())
			return null;
		
		SortedSet<String> ss = new TreeSet<String>();

		Iterator<String> it = versions.keySet().iterator();
		while (it.hasNext())
			ss.add(it.next());
		
		return versions.get(ss.last());
	}
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getPartNumber() {
		return partNumber;
	}

	public void setPartNumber(String partNumber) {
		this.partNumber = partNumber;
	}

	public String getProductLine() {
		return productLine;
	}

	public void setProductLine(String productLine) {
		this.productLine = productLine;
	}

	public String getSuitableDepartment() {
		return suitableDepartment;
	}

	public void setSuitableDepartment(String suitableDepartment) {
		this.suitableDepartment = suitableDepartment;
	}

	public Map<String, WorkInstructionVersion> getVersions() {
		return versions;
	}

	public void setVersions(Map<String, WorkInstructionVersion> versions) {
		this.versions = versions;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public Set<Station> getStations() {
		return stations;
	}

	public void setStations(Set<Station> stations) {
		this.stations = stations;
	}

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?