294 lines
7.5 KiB
Java
294 lines
7.5 KiB
Java
package pickMaint;
|
|
|
|
import java.sql.ResultSet;
|
|
import java.sql.SQLException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.Date;
|
|
import java.util.logging.Logger;
|
|
|
|
/**
|
|
* This class is essentially just an Object representation of a single record in LOOMDS/LOOMDS2.
|
|
*
|
|
* The constructor takes a reference to an AS400Interface only in case we need to pull "no bonus" hours and picks from LOOMDS2.
|
|
* See below: if(deleteCode.equalsIgnoreCase("N")) { ... }
|
|
*
|
|
* The bulk of the object is created using the java.sql.ResultSet that is passed to the constructor. This ResultSet is expected to be
|
|
* generated by a particular query stored in AS400Interface.java
|
|
*
|
|
* The rest of the class is just getters/setters.
|
|
*
|
|
* @author Wesley Ray
|
|
*/
|
|
public class LoomDSRecord implements Comparable<Object> {
|
|
|
|
private static final Logger LOGGER = Logger.getLogger(LoomDSRecord.class.getName());
|
|
|
|
private Date date;
|
|
private int shift;
|
|
private int loomNumber;
|
|
private int weaverNumber;
|
|
private String weaverName;
|
|
private String ldStyle; //TRL, BLN, or SAM
|
|
private double hours;
|
|
private int picks;
|
|
private float picksPerHourBonus;
|
|
private float picksPerHourNoBonus;
|
|
private String downTimeCode;
|
|
private String downTimeCodeDescription;
|
|
private int cut;
|
|
private String cutSuffix;
|
|
private String typeCode;
|
|
private String deleteCode;
|
|
|
|
private boolean bonus;
|
|
private boolean changed = false; //Never ended up using this, not a bad idea though. leaving it here just in case
|
|
|
|
public LoomDSRecord(AS400Interface as400, ResultSet row) throws SQLException {
|
|
date = AS400Interface.intToDate(row.getInt(1));
|
|
loomNumber = row.getInt(2);
|
|
shift = row.getInt(3);
|
|
weaverNumber = row.getInt(4);
|
|
weaverName = row.getString(5).trim();
|
|
ldStyle = row.getString(6).trim();
|
|
hours = row.getDouble(7);
|
|
picks = row.getInt(8);
|
|
picksPerHourBonus = row.getFloat(11);
|
|
picksPerHourNoBonus = row.getFloat(12);
|
|
downTimeCode = row.getString(13).trim();
|
|
downTimeCodeDescription = AS400Interface.dtCodeLookup(downTimeCode);
|
|
cut = row.getInt(14);
|
|
cutSuffix = row.getString(15).trim();
|
|
typeCode = row.getString(16).trim();
|
|
deleteCode = row.getString(17);
|
|
|
|
bonus = !((weaverNumber > 699 && weaverNumber < 703) || (ldStyle.equalsIgnoreCase("TRL") || ldStyle.equalsIgnoreCase("BLN") || deleteCode.equalsIgnoreCase("N")));
|
|
|
|
if(deleteCode.equalsIgnoreCase("N")){
|
|
LOGGER.fine(logPrefix() + "is flagged NO_BONUS need to fetch hours and picks from LOOMDS2.");
|
|
float[] values = as400.getLoomDS2HoursPicks(AS400Interface.dateToInt(date), loomNumber, shift, weaverNumber);
|
|
hours = values[0];
|
|
picks = (int) values[1];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @return the weaverNumber
|
|
*/
|
|
public final int getWeaverNumber() {
|
|
return weaverNumber;
|
|
}
|
|
|
|
/**
|
|
* @param weaverNumber the weaverNumber to set
|
|
*/
|
|
public final void setWeaverNumber(int weaverNumber) {
|
|
LOGGER.info("Loom: " + loomNumber + " - " + ((shift == 1) ? "1st" : (shift == 2) ? "2nd" : (shift == 3) ? "3rd" : "") + " shift - " + new SimpleDateFormat("MM/dd/yyyy").format(date) +
|
|
" - Changing weaver from: " + weaverName + " (" + this.weaverNumber + ") to: " + AS400Interface.weaverLookup(weaverNumber) + " (" + weaverNumber + ")");
|
|
this.weaverNumber = weaverNumber;
|
|
this.weaverName = AS400Interface.weaverLookup(weaverNumber);
|
|
bonus = !((weaverNumber > 699 && weaverNumber < 703) || (ldStyle.equalsIgnoreCase("TRL") || ldStyle.equalsIgnoreCase("BLN")));
|
|
changed = true;
|
|
}
|
|
|
|
/**
|
|
* @return the ldStyle
|
|
*/
|
|
public final String getLdStyle() {
|
|
return ldStyle;
|
|
}
|
|
|
|
/**
|
|
* @param ldStyle the ldStyle to set
|
|
*/
|
|
public final void setLdStyle(String ldStyle) {
|
|
LOGGER.info(logPrefix() + "- Changing LDSTYL from: " + this.ldStyle + " to: " + ldStyle);
|
|
this.ldStyle = ldStyle;
|
|
bonus = !((weaverNumber > 699 && weaverNumber < 703) || (ldStyle.equalsIgnoreCase("TRL") || ldStyle.equalsIgnoreCase("BLN")));
|
|
changed = true;
|
|
}
|
|
|
|
/**
|
|
* @return the hours
|
|
*/
|
|
public final double getHours() {
|
|
return hours;
|
|
}
|
|
|
|
/**
|
|
* @param hours the hours to set
|
|
*/
|
|
public final void setHours(double hours) {
|
|
LOGGER.info(logPrefix() + "- Changing hours from: " + this.hours + " to: " + hours);
|
|
this.hours = hours;
|
|
changed = true;
|
|
}
|
|
|
|
/**
|
|
* @return the picks
|
|
*/
|
|
public final int getPicks() {
|
|
return picks;
|
|
}
|
|
|
|
/**
|
|
* @param picks the picks to set
|
|
*/
|
|
public final void setPicks(int picks) {
|
|
LOGGER.info(logPrefix() + "- Changing picks from: " + this.picks + " to: " + picks);
|
|
this.picks = picks;
|
|
changed = true;
|
|
}
|
|
|
|
public final int getMaxPicks(){
|
|
return (int) ((hours * (bonus ? picksPerHourBonus : picksPerHourNoBonus)) + 0.5); //The +0.5 combined with the (int) cast creates the effect of rounding up to nearest whole number
|
|
}
|
|
|
|
/**
|
|
* @return the downTimeCode
|
|
*/
|
|
public final String getDownTimeCode() {
|
|
return downTimeCode;
|
|
}
|
|
|
|
/**
|
|
* @param downTimeCode the downTimeCode to set
|
|
*/
|
|
public final void setDownTimeCode(String downTimeCode) {
|
|
LOGGER.info(logPrefix() + "- Changing down time code from: " + this.downTimeCode + " to: " + downTimeCode);
|
|
this.downTimeCode = downTimeCode;
|
|
this.downTimeCodeDescription = AS400Interface.dtCodeLookup(downTimeCode);
|
|
changed = true;
|
|
}
|
|
|
|
/**
|
|
* @return the typeCode
|
|
*/
|
|
public final String getTypeCode() {
|
|
return typeCode;
|
|
}
|
|
|
|
/**
|
|
* @param typeCode the typeCode to set
|
|
*/
|
|
public final void setTypeCode(String typeCode) {
|
|
LOGGER.info(logPrefix() + "- Changing type code from: " + this.typeCode + " to: " + typeCode);
|
|
this.typeCode = typeCode;
|
|
changed = true;
|
|
}
|
|
|
|
/**
|
|
* @return the date
|
|
*/
|
|
public final Date getDate() {
|
|
return date;
|
|
}
|
|
|
|
/**
|
|
* @return the shift
|
|
*/
|
|
public final int getShift() {
|
|
return shift;
|
|
}
|
|
|
|
/**
|
|
* @return the loomNumber
|
|
*/
|
|
public final int getLoomNumber() {
|
|
return loomNumber;
|
|
}
|
|
|
|
/**
|
|
* @return the weaverName
|
|
*/
|
|
public final String getWeaverName() {
|
|
return weaverName;
|
|
}
|
|
|
|
public final String getWeaverNameDisplay(){
|
|
return weaverName + " (" + weaverNumber + ")";
|
|
}
|
|
|
|
/**
|
|
* @return the picksPerHourBonus
|
|
*/
|
|
public final float getPicksPerHourBonus() {
|
|
return picksPerHourBonus;
|
|
}
|
|
|
|
/**
|
|
* @return the picksPerHourNoBonus
|
|
*/
|
|
public final float getPicksPerHourNoBonus() {
|
|
return picksPerHourNoBonus;
|
|
}
|
|
|
|
/**
|
|
* @return the downTimeCodeDescription
|
|
*/
|
|
public final String getDownTimeCodeDescription() {
|
|
return downTimeCodeDescription;
|
|
}
|
|
|
|
public final String getformattedDowntimeReason(){
|
|
if(downTimeCodeDescription != null)
|
|
return "(" + downTimeCode + ") " + downTimeCodeDescription;
|
|
else
|
|
return "";
|
|
}
|
|
|
|
/**
|
|
* @return the cut
|
|
*/
|
|
public final int getCut() {
|
|
return cut;
|
|
}
|
|
|
|
/**
|
|
* @return the cutSuffix
|
|
*/
|
|
public final String getCutSuffix() {
|
|
return cutSuffix;
|
|
}
|
|
|
|
public final String getFormattedCutNumber(){
|
|
if(cut < 1)
|
|
return "";
|
|
if(cutSuffix.length() == 0)
|
|
return "" + cut;
|
|
return cut + "-" + cutSuffix;
|
|
}
|
|
|
|
/**
|
|
* @return the deleteCode
|
|
*/
|
|
public final String getDeleteCode() {
|
|
return deleteCode;
|
|
}
|
|
|
|
/**
|
|
* @return the bonus
|
|
*/
|
|
public final boolean isBonus() {
|
|
return bonus;
|
|
}
|
|
|
|
public final boolean changed(){
|
|
return changed;
|
|
}
|
|
|
|
private String logPrefix(){
|
|
return "Loom: " + loomNumber + " - " + ((shift == 1) ? "1st" : (shift == 2) ? "2nd" : (shift == 3) ? "3rd" : "") + " shift - "
|
|
+ new SimpleDateFormat("MM/dd/yyyy").format(date) + " Weaver: " + weaverName + " (" + weaverNumber + ") ";
|
|
}
|
|
|
|
@Override
|
|
public int compareTo(Object o) {
|
|
if(o instanceof LoomDSRecord){
|
|
return loomNumber - ((LoomDSRecord) o).getLoomNumber();
|
|
} else {
|
|
throw new RuntimeException("Something screwed when sorting LoomDSRecord array");
|
|
}
|
|
}
|
|
|
|
}
|