package com.northglass.service.identifymachine;
|
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.swing.text.html.HTML;
|
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Component;
|
import org.springframework.transaction.annotation.Transactional;
|
|
import com.northglass.constants.StateConstants.ConnectState;
|
import com.northglass.constants.StateConstants.CountMachineTaskState;
|
import com.northglass.constants.StateConstants.GlassArrangeState;
|
import com.northglass.constants.StateConstants.GlassState;
|
import com.northglass.constants.StateConstants.sendGlassState;
|
import com.northglass.entity.CountMachineTask;
|
import com.northglass.entity.Glass;
|
import com.northglass.entity.GlassOrder;
|
import com.northglass.entity.GlassTest;
|
import com.northglass.entity.IdentifyFloor;
|
import com.northglass.entity.IdentifyMachine;
|
import com.northglass.entity.IdentifyPattern;
|
import com.northglass.entity.OptPattern;
|
import com.northglass.entity.PreprocessingGlass;
|
import com.northglass.entity.RawPackageTxt;
|
import com.northglass.entity.ShelfStatu;
|
import com.northglass.entity.SingalGlass;
|
import com.northglass.entity.TestOut;
|
import com.northglass.entity.TougheningGlass;
|
import com.northglass.listener.IdentifyMachineClientListener;
|
import com.northglass.repository.CountMachineDao;
|
import com.northglass.repository.CountMachineTaskDao;
|
import com.northglass.repository.GlassDao;
|
import com.northglass.repository.GlassOrderDao;
|
import com.northglass.repository.GlassTestDao;
|
import com.northglass.repository.IdentifyFloorDao;
|
import com.northglass.repository.IdentifyMachineDao;
|
import com.northglass.repository.IdentifyPatternDao;
|
import com.northglass.repository.PreprocessingGlassDao;
|
import com.northglass.repository.RawPackageTxtDao;
|
import com.northglass.repository.ShelfStatuDao;
|
import com.northglass.repository.SingalGlassDao;
|
import com.northglass.repository.TestOutDao;
|
import com.northglass.repository.TougheningGlassDao;
|
import com.northglass.service.message.IdentifyMachineMessageProcessor;
|
|
@Component
|
@Transactional
|
public class IdentifyMachineService {
|
|
@Autowired
|
private TestOutDao testOutDao;
|
|
@Autowired
|
private IdentifyMachineDao identifyMachineDao;
|
|
@Autowired
|
private IdentifyFloorDao identifyFloorDao;
|
|
@Autowired
|
private IdentifyMachineMessageProcessor processor;
|
|
@Autowired
|
private CountMachineTaskDao countMachineTaskDao;
|
|
@Autowired
|
private CountMachineDao countMachineDao;
|
|
@Autowired
|
private GlassDao glassDao;
|
|
@Autowired
|
private SingalGlassDao singalGlassDao;
|
|
@Autowired
|
private PreprocessingGlassDao preprocessingGlassDao;
|
|
@Autowired
|
private IdentifyPatternDao identifyPatternDao;
|
|
@Autowired
|
private RawPackageTxtDao rawPackageTxtDao;
|
|
@Autowired
|
private TougheningGlassDao tougheningGlassDao;
|
|
@Autowired
|
private ShelfStatuDao shelfStatuDao;
|
|
@Autowired
|
private GlassTestDao glassTestDao;
|
|
@Autowired
|
private GlassOrderDao glassOrderDao;
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(IdentifyMachineService.class);
|
|
public void connect() {
|
LOGGER.debug("> Start connect");
|
|
List<IdentifyMachine> identifyMachineList = identifyMachineDao.findAll();
|
|
// 若监听线程为空,则新建监听线程
|
for (IdentifyMachine identifyMachine : identifyMachineList) {
|
if (identifyMachine.getServerConnection().getThread() == null) {
|
LOGGER.debug("创建新的测量台【" + identifyMachine.getNumber() + "】监听线程!");
|
Thread thread = new Thread(new IdentifyMachineClientListener(identifyMachine, this));
|
thread.start();
|
|
setConnectState(identifyMachine, ConnectState.CONNECTING);
|
identifyMachine.getServerConnection().setThread(thread);
|
}
|
}
|
|
LOGGER.debug("> End connect");
|
}
|
|
public void setConnectState(IdentifyMachine identifyMachine, String connecting) {
|
identifyMachine.setConnectState(connecting);
|
identifyMachine.setModifyTime(new Date());
|
identifyMachineDao.save(identifyMachine);
|
}
|
|
public String processMessage(String message, IdentifyMachine machineClient) {
|
return processor.generateReturnMessage(message, machineClient);
|
}
|
|
public void getendtime(String name) {
|
List<TestOut> testOuts = testOutDao.findByName(name);
|
if (testOuts.size() > 0) {
|
TestOut testOut = testOuts.get(testOuts.size() - 1);
|
if (testOut.getEnd_time() != null && !testOut.getEnd_time().equals("")) {
|
TestOut test = new TestOut(name);
|
test.setStart_time(new Date());
|
testOutDao.save(test);
|
} else {
|
testOut.setEnd_time(new Date());
|
testOutDao.save(testOut);
|
}
|
} else {
|
TestOut testOut = new TestOut(name + "start");
|
testOut.setStart_time(new Date());
|
testOutDao.save(testOut);
|
}
|
}
|
|
public void getright(String name) {
|
TestOut testOut = new TestOut(name);
|
testOut.setStart_time(new Date());
|
testOutDao.save(testOut);
|
}
|
//findToIdentifyGlass
|
public List<Glass> getGlass() {
|
List<Glass> glass=new ArrayList<Glass>();
|
glass=glassDao.findToIdentifyGlass();
|
return glass;
|
}
|
public Glass getOnlyGlass(IdentifyMachine machineClient, List<Glass> glasses, double length, double width) {
|
IdentifyFloor idf = identifyFloorDao.findOne(1L);
|
List<Glass> glasses2 = new ArrayList<Glass>();
|
// 产生匹配详情
|
PreprocessingGlass preprocessingGlass = preprocessingGlassDao.findOne(1L);
|
preprocessingGlass.setActualLength(length);
|
preprocessingGlass.setActualWidth(width);
|
preprocessingGlass.setStatu("匹配失败");
|
if (glasses.size() > 0) {
|
for (Glass glass : glasses) {
|
//误差范围内的匹配
|
if ((glass.getStartlength() - idf.getCeiling()< length
|
&& glass.getStartlength() + idf.getFloor() > length
|
&& glass.getStartwidth() - idf.getCeiling() < width
|
&& glass.getStartwidth() + idf.getFloor() > width)
|
|| (glass.getStartlength() - idf.getCeiling() < width
|
&& glass.getStartlength() + idf.getFloor() > width
|
&& glass.getStartwidth() - idf.getCeiling() < length
|
&& glass.getStartwidth() + idf.getFloor() > length)) {
|
glasses2.add(glass);
|
break;
|
}
|
}
|
if (glasses2.size() == 1) {
|
Glass g = glasses2.get(0);
|
TougheningGlass tougheningGlass = new TougheningGlass();
|
tougheningGlass.setActualLength(length);
|
tougheningGlass.setActualWidth(width);
|
tougheningGlass.setGlass(g);
|
tougheningGlass.setState("等待中");
|
|
GlassTest test = new GlassTest(length,width,new Date());
|
test.setLength(g.getStartlength());
|
test.setWidth(g.getStartwidth());
|
|
preprocessingGlass.setLength(g.getStartlength());
|
preprocessingGlass.setWidth(g.getStartwidth());
|
preprocessingGlass.setThickness(g.getThickness());
|
preprocessingGlass.setTxtname(g.getRawPackageTxt().getTxt_name());
|
preprocessingGlass.setStatu("匹配成功");
|
preprocessingGlass.setColor(g.getColor());
|
preprocessingGlass.setGlass(g);
|
|
//此类玻璃 完成达到完成片数 修改状态为已完成 修改 完成片数+1
|
if (g.getPieces() == g.getCompletePieces()+1) {
|
g.setState(GlassState.TO_COMPLETE);
|
}
|
g.setCompletePieces(g.getCompletePieces() + 1);
|
glassDao.save(g);
|
glassTestDao.save(test);
|
tougheningGlassDao.save(tougheningGlass);
|
preprocessingGlassDao.save(preprocessingGlass);
|
return g;
|
}
|
}else {
|
preprocessingGlass.setLength(0);
|
preprocessingGlass.setWidth(0);
|
preprocessingGlass.setThickness(0);
|
preprocessingGlass.setTxtname("");
|
preprocessingGlass.setStatu("无玻璃信息对比");
|
preprocessingGlassDao.save(preprocessingGlass);
|
LOGGER.debug("没有玻璃信息对比,请查明原因");
|
return null;
|
}
|
return null;
|
}
|
|
/**
|
*
|
* 功能:测量台用于对比数据(弃用)
|
*
|
**/
|
public SingalGlass getOnlySingalGlass(IdentifyMachine machineClient, List<SingalGlass> glasses, double length,
|
double width) {
|
IdentifyFloor idf = identifyFloorDao.findOne(1L);
|
List<SingalGlass> glasses2 = new ArrayList<SingalGlass>();
|
for (SingalGlass glass : glasses) {
|
if ((glass.getLength() - idf.getCeiling() + glass.getArrangePieces() < length
|
&& glass.getLength() + idf.getFloor() + glass.getArrangePieces() > length
|
&& glass.getWidth() - idf.getCeiling() + glass.getArrangePieces() < width
|
&& glass.getWidth() + idf.getFloor() + glass.getArrangePieces() > width)
|
|| (glass.getLength() - idf.getCeiling() + glass.getArrangePieces() < width
|
&& glass.getLength() + idf.getFloor() + glass.getArrangePieces() > width
|
&& glass.getWidth() - idf.getCeiling() + glass.getArrangePieces() < length
|
&& glass.getWidth() + idf.getFloor() + glass.getArrangePieces() > length)) {
|
// for (SingalGlass gla :glasses2) {
|
// if
|
// (!(glass.getLength()==gla.getLength()&&glass.getWidth()==gla.getWidth())||!(glass.getLength()==gla.getWidth()&&glass.getWidth()==gla.getLength()))
|
// {
|
glasses2.add(glass);
|
// }
|
// }
|
|
}
|
}
|
if (glasses2.size() == 1) {
|
SingalGlass g = glasses2.get(0);
|
if (g.getLength() - idf.getCeiling() + g.getArrangePieces() < width
|
&& g.getLength() + idf.getFloor() + g.getArrangePieces() > width
|
&& g.getWidth() - idf.getCeiling() + g.getArrangePieces() < length
|
&& g.getWidth() + idf.getFloor() + g.getArrangePieces() > length) {
|
CountMachineTask task = new CountMachineTask();
|
countMachineTaskDao.save(task);
|
} else {
|
CountMachineTask task = new CountMachineTask();
|
countMachineTaskDao.save(task);
|
}
|
return glasses2.get(0);
|
}
|
return null;
|
}
|
|
public Glass gerMatchGlass(IdentifyMachine machineClient, RawPackageTxt rawPackageTxt, double length,
|
double width) {
|
// // IdentifyFloor idf = identifyFloorDao.findOne(1L);
|
// List<Glass> glasses = glassDao.findByRaw(rawPackageTxt.getId());
|
// if (glasses.size() > 0) {
|
// return getOnlyGlass(machineClient, glasses, length, width);
|
// } else {
|
// // 把singalglass里面的数据精简放到glass里面去
|
// List<Glass> glasses2 = singalToGlass(rawPackageTxt);
|
// if (glasses2.size() > 0) {
|
// return getOnlyGlass(machineClient, glasses2, length, width);
|
// }
|
// }
|
return null;
|
}
|
|
// private List<Glass> singalToGlass(RawPackageTxt rawPackageTxt) {
|
// // 得到singalglass数据
|
// List<Glass> glasses = new ArrayList<Glass>();
|
// List<SingalGlass> singalGlasses = singalGlassDao.findByRaw(rawPackageTxt.getId());
|
// if (singalGlasses.size() > 0) {
|
// for (SingalGlass singalGlass : singalGlasses) {
|
// OptPattern optPattern = singalGlass.getOptPattern();
|
// if (glasses.size() > 0) {
|
// for (int i = 0; i <= glasses.size() - 1; i++) {
|
// Glass glass = glasses.get(i);
|
// if ((glass.getWidth() == singalGlass.getWidth())
|
// && (glass.getLength() == singalGlass.getLength())
|
// && (glass.getApart_id().equals(singalGlass.getApart_id()))) {
|
// glass.setPieces(glass.getPieces() + optPattern.getPieces());
|
// glassDao.save(glass);
|
// break;
|
// }
|
// if (i == glasses.size() - 1) {
|
// Glass gl = new Glass(GlassArrangeState.MEASURE, 0, singalGlass.getLength(),
|
// singalGlass.getWidth(), singalGlass.getThickness(), singalGlass.getColor(),
|
// singalGlass.getCustomer(), GlassArrangeState.MEASURE, "", singalGlass.getApart_id(),
|
// singalGlass.getManufacture_batch(),
|
// singalGlass.getPieces() * optPattern.getPieces(), 0, 0,
|
// singalGlass.getApplication(), singalGlass.getProduction(),
|
// singalGlass.getFloor_number(), singalGlass.getOrder_number(),
|
// singalGlass.getPiece_sign(), singalGlass.getRemark(), sendGlassState.NOTSEND,
|
// sendGlassState.NOTSEND);
|
// gl.setRawPackageTxt(rawPackageTxt);
|
// gl.setStartlength(singalGlass.getStartlength());
|
// gl.setStartwidth(singalGlass.getStartwidth());
|
// glassDao.save(gl);
|
// glasses.add(gl);
|
// break;
|
// }
|
//
|
// }
|
// } else {
|
// Glass glass = new Glass(GlassArrangeState.MEASURE, 0, singalGlass.getLength(),
|
// singalGlass.getWidth(), singalGlass.getThickness(), singalGlass.getColor(),
|
// singalGlass.getCustomer(), GlassArrangeState.MEASURE, "", singalGlass.getApart_id(),
|
// singalGlass.getManufacture_batch(), singalGlass.getPieces() * optPattern.getPieces(), 0, 0,
|
// singalGlass.getApplication(), singalGlass.getProduction(), singalGlass.getFloor_number(),
|
// singalGlass.getOrder_number(), singalGlass.getPiece_sign(), singalGlass.getRemark(),
|
// sendGlassState.NOTSEND, sendGlassState.NOTSEND);
|
// glass.setRawPackageTxt(rawPackageTxt);
|
// glass.setStartlength(singalGlass.getStartlength());
|
// glass.setStartwidth(singalGlass.getStartwidth());
|
// glassDao.save(glass);
|
// glasses.add(glass);
|
// }
|
// }
|
// }
|
// return glasses;
|
// }
|
|
public Map<String, Object> getCeliangManageData(String groups) {
|
|
// Long machineId = Long.valueOf(groups);
|
PreprocessingGlass preprocessingGlass = preprocessingGlassDao.findOne(1L);
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
param.put("actuallength", preprocessingGlass.getActualLength());
|
param.put("actualwidth", preprocessingGlass.getActualWidth());
|
param.put("color", preprocessingGlass.getColor());
|
param.put("txtname", preprocessingGlass.getTxtname());
|
param.put("thickness", preprocessingGlass.getThickness());
|
param.put("status", preprocessingGlass.getStatu());
|
if (preprocessingGlass.getGlass() != null) {
|
param.put("width", preprocessingGlass.getWidth());
|
param.put("length", preprocessingGlass.getLength());
|
param.put("glassid", preprocessingGlass.getGlass().getId());
|
}
|
if (preprocessingGlass.getStatu().equals("匹配失败") ||preprocessingGlass.getStatu().equals("多数据匹配")) {
|
param.put("img", "quxiao.png");
|
} else {
|
param.put("img", "zhengque.png");
|
}
|
int totalPieces = 0;
|
int completePieces = 0;
|
if (preprocessingGlass.getRawPackageTxt()!=null) {
|
List<Glass> glasses = glassDao.findByRaw(preprocessingGlass.getRawPackageTxt().getId());
|
if (glasses.size()>0) {
|
for (Glass glass : glasses) {
|
completePieces = completePieces + glass.getCompletePieces();
|
totalPieces = totalPieces + glass.getPieces();
|
}
|
}
|
}
|
|
param.put("totalPieces", totalPieces);
|
param.put("completePieces", completePieces);
|
param.put("leftPieces", totalPieces - completePieces);
|
param.put("progress", ((double) completePieces / (double) totalPieces * 100) + "%");
|
|
// 测量结果显示。
|
// - 若找到匹配玻璃,则显示结果为匹配成功,不需要人工处理,自动执行送片;
|
// - 若没有找到识别玻璃,则显示两个按钮
|
// - 一个是重新匹配,允许用户校正并重新测量;
|
// - 另一个是匹配失败,需要用户自己将玻璃移除,并确认;
|
StringBuffer html = new StringBuffer();
|
param.put("identifyResultHtml", html.toString());
|
|
return param;
|
|
}
|
|
public IdentifyPattern getpatern(String groups) {
|
LOGGER.debug("group:" + groups);
|
return identifyPatternDao.findById(1L);
|
}
|
|
public IdentifyFloor getfloor(String groups) {
|
LOGGER.debug("group:" + groups);
|
return identifyFloorDao.findOne(1L);
|
}
|
|
public void modifyGlass(String txtid, String ids) {
|
// 把原先的尺寸全部删除
|
// 把新的尺寸都给算进去
|
RawPackageTxt txt = rawPackageTxtDao.findByTxtName(ids);
|
LOGGER.debug(txtid);
|
// List<Glass> glasses = glassDao.findByRaw(Long.parseLong(txtid));
|
PreprocessingGlass ga=preprocessingGlassDao.findOne(1L);
|
ga.setGlass(null);
|
preprocessingGlassDao.save(ga);
|
// List<CountMachineTask> countMachineTaskes = countMachineTaskDao.findByRaw(txt.getId());
|
// if (countMachineTaskes.size()>0) {
|
// for (CountMachineTask ctask : countMachineTaskes) {
|
// countMachineTaskDao.delete(ctask);
|
// }
|
// }
|
// if (glasses.size() > 0) {
|
// for (Glass glass : glasses) {
|
// List<CountMachineTask> countMachineTaskes = countMachineTaskDao.findByGlass(glass.getId());
|
// if (countMachineTaskes.size()>0) {
|
// for (CountMachineTask ctask : countMachineTaskes) {
|
// countMachineTaskDao.delete(ctask);
|
// }
|
// }
|
// glassDao.delete(glass);
|
// }
|
// }
|
|
|
if (txt != null) {
|
// singalToGlass(txt);
|
// 修改identifyPattern
|
IdentifyPattern pattern = identifyPatternDao.findOne(1L);
|
pattern.setRawPackageTxt(txt);
|
}
|
}
|
|
public String getbatch(String groups) {
|
IdentifyPattern identifyPattern = identifyPatternDao.findById(1L);
|
return identifyPattern.getRawPackageTxt().getTxt_name();
|
}
|
/****
|
*
|
*
|
* 功能:玻璃尺寸非常接近时,找出可对应的单号
|
*
|
*
|
*
|
* **/
|
public List<Glass> getglassList(String groups) {
|
// IdentifyPattern identifyPattern = identifyPatternDao.findById(1L);
|
PreprocessingGlass preprocessingGlass = preprocessingGlassDao.findOne(1L);
|
// RawPackageTxt txt = identifyPattern.getRawPackageTxt();
|
if (preprocessingGlass.getRawPackageTxt() ==null) {
|
return null;
|
}
|
List<Glass> glasses = glassDao.findByRawAndState(preprocessingGlass.getRawPackageTxt().getId());
|
IdentifyFloor idf = identifyFloorDao.findOne(1L);
|
List<Glass> glasses2 = new ArrayList<Glass>();
|
// 产生匹配详情
|
|
double length = preprocessingGlass.getActualLength();
|
double width = preprocessingGlass.getActualWidth();
|
// 匹配对比
|
if (preprocessingGlass.getStatu().equals("匹配失败")|| preprocessingGlass.getStatu().equals("多数据匹配")) {
|
for (Glass glass : glasses) {
|
if ((glass.getStartlength() - idf.getCeiling() < length
|
&& glass.getStartlength() + idf.getFloor()> length
|
&& glass.getStartwidth() - idf.getCeiling() < width
|
&& glass.getStartwidth() + idf.getFloor() > width)
|
|| (glass.getStartlength() - idf.getCeiling() < width
|
&& glass.getStartlength() + idf.getFloor() > width
|
&& glass.getStartwidth() - idf.getCeiling() < length
|
&& glass.getStartwidth() + idf.getFloor() > length)) {
|
if (glasses2.size() > 0) {
|
for (Glass gla : glasses2) {
|
if (!(glass.getLength() == gla.getLength() && glass.getWidth() == gla.getWidth())
|
|| !(glass.getLength() == gla.getWidth() && glass.getWidth() == gla.getLength())) {
|
glasses2.add(glass);
|
break;
|
}
|
}
|
}else {
|
glasses2.add(glass);
|
}
|
}
|
}
|
}
|
return glasses2;
|
}
|
public void Deleteglalls(String groups, String glassid) {
|
//破损
|
PreprocessingGlass gs = preprocessingGlassDao.findOne(1L);
|
if(gs.getFlag()==0){
|
Glass glass=glassDao.findOne(Integer.valueOf(glassid).longValue());
|
glass.setCompletePieces(glass.getCompletePieces()+1);
|
glass.setDamagePieces(glass.getDamagePieces()+1);
|
gs.setFlag(3);
|
preprocessingGlassDao.save(gs);
|
}
|
}
|
public void modify(String groups, String glassid) {
|
PreprocessingGlass preprocessingGlass = preprocessingGlassDao.findOne(Long.parseLong(groups));
|
//找出当前的玻璃,并修改指认
|
if(preprocessingGlass.getFlag()==0){
|
Glass glass = glassDao.findOne(Long.parseLong(glassid));
|
preprocessingGlass.setTxtname(glass.getRawPackageTxt().getTxt_name());
|
preprocessingGlass.setGlass(glass);
|
preprocessingGlass.setStatu("匹配成功");
|
preprocessingGlass.setFlag(1);
|
preprocessingGlass.setLength(glass.getStartlength());
|
preprocessingGlass.setWidth(glass.getStartwidth());
|
preprocessingGlass.setColor(glass.getColor());
|
preprocessingGlass.setThickness(glass.getThickness());
|
|
GlassTest test = new GlassTest(glass.getLength(),glass.getWidth(),preprocessingGlass.getActualLength(),preprocessingGlass.getActualWidth(),new Date());
|
test.setLength(glass.getLength());
|
test.setWidth(glass.getWidth());
|
|
TougheningGlass tougheningGlass = new TougheningGlass();
|
tougheningGlass.setGlass(glass);
|
tougheningGlass.setActualLength(glass.getLength());
|
tougheningGlass.setActualWidth(glass.getWidth());
|
tougheningGlass.setState("等待中");
|
if (glass.getPieces() == glass.getCompletePieces()+1) {
|
glass.setState(GlassState.TO_COMPLETE);
|
}
|
glass.setCompletePieces(glass.getCompletePieces()+1);
|
glassDao.save(glass);
|
glassTestDao.save(test);
|
tougheningGlassDao.save(tougheningGlass);
|
preprocessingGlassDao.save(preprocessingGlass);
|
}
|
|
}
|
|
public void modifyErrorRange(String groups, String floor, String ceiling) {
|
IdentifyFloor identifyFloor = identifyFloorDao.findOne(1L);
|
if (identifyFloor != null) {
|
identifyFloor.setCeiling(Double.parseDouble(ceiling));
|
identifyFloor.setFloor(Double.parseDouble(floor));
|
identifyFloorDao.save(identifyFloor);
|
}
|
}
|
|
public void pattern(String groups, String patterns) {
|
IdentifyPattern pattern = identifyPatternDao.findOne(1L);
|
LOGGER.debug("对应的id:"+pattern);
|
if (patterns.equals("old")) {
|
pattern.setPattern("切割匹配");
|
}else if (patterns.equals("now")) {
|
pattern.setPattern("不匹配");
|
}else{
|
pattern.setPattern("订单匹配");
|
}
|
identifyPatternDao.save(pattern);
|
}
|
|
public void deleteData() {
|
|
}
|
|
public void posun() {
|
PreprocessingGlass preprocessingGlass = preprocessingGlassDao.findOne(1L);
|
if (preprocessingGlass.getStatu().equals("匹配失败") ||preprocessingGlass.getStatu().equals("多数据匹配")) {
|
preprocessingGlass.setFlag(2);
|
preprocessingGlass.setStatu("匹配失败");
|
preprocessingGlassDao.save(preprocessingGlass);
|
}
|
}
|
|
public String selectData() {
|
StringBuffer html = new StringBuffer();
|
List<TougheningGlass> tougheningGlasses = tougheningGlassDao.findInWork();
|
if (tougheningGlasses.size()>0) {
|
for (TougheningGlass tougheningGlass:tougheningGlasses) {
|
html.append("<td>").append(tougheningGlass.getActualLength());
|
html.append("</td>");
|
}
|
}
|
return html.toString();
|
}
|
|
public String damage() {
|
StringBuffer html = new StringBuffer();
|
RawPackageTxt txt = rawPackageTxtDao.findAcceptedByGroup("1");
|
List<Glass> glasses = glassDao.findGlassByBatchs(txt.getTxt_name());
|
if (glasses.size()>0) {
|
for(Glass glass : glasses){
|
html.append("<tr><td>").append(glass.getId()).append("</td>");
|
html.append("<td>").append(glass.getManufacture_batch()).append("</td>");
|
html.append("<td>").append(glass.getWidth()).append("</td>");
|
html.append("<td>").append(glass.getLength()).append("</td>");
|
html.append("<td>").append(glass.getThickness()).append("</td>");
|
html.append("<td>").append(glass.getColor()).append("</td>");
|
html.append("<td>").append(glass.getPieces()).append("</td>");
|
html.append("<td>").append(glass.getCompletePieces()).append("</td>");
|
html.append("<td>").append(glass.getDamagePieces()).append("</td>");
|
html.append("<td><a class='btn btn-danger' onclick='print("+glass.getId()+")'> ").append("破损").append("</a></td>");
|
html.append("</tr>");
|
}
|
}
|
return html.toString();
|
}
|
|
public String review() {
|
StringBuffer html = new StringBuffer();
|
List<TougheningGlass> tougheningGlasses = tougheningGlassDao.findWaitingGlass();
|
if (tougheningGlasses.size()>0) {
|
for(TougheningGlass tougheningGlass : tougheningGlasses){
|
Glass glass = tougheningGlass.getGlass();
|
html.append("<tr><td>").append(glass.getId()).append("</td>");
|
html.append("<td>").append(glass.getManufacture_batch()).append("</td>");
|
html.append("<td>").append(glass.getWidth()).append("</td>");
|
html.append("<td>").append(glass.getLength()).append("</td>");
|
html.append("<td>").append(glass.getThickness()).append("</td>");
|
html.append("<td>").append(glass.getColor()).append("</td>");
|
html.append("<td>").append(glass.getPieces()).append("</td>");
|
html.append("<td>").append(glass.getCompletePieces()).append("</td>");
|
html.append("<td>").append(glass.getDamagePieces()).append("</td>");
|
html.append("<td><a class='btn btn-danger' onclick='print("+tougheningGlass.getId()+")'> ").append("退回").append("</a></td>");
|
html.append("</tr>");
|
}
|
}
|
return html.toString();
|
}
|
|
|
public String checkEnd(String id) {
|
Glass glass = glassDao.findOne(Long.parseLong(id));
|
if (glass != null) {
|
glass.setDamagePieces(glass.getDamagePieces()+1);
|
if (glass.getCompletePieces()+glass.getDamagePieces() == glass.getPieces()) {
|
glass.setState("已识别");
|
}
|
glassDao.save(glass);
|
ps(glass);//玻璃破损
|
return "ok";
|
}else {
|
return "noglass";
|
}
|
}
|
//进片前破损
|
public void ps(Glass glass){
|
List<GlassOrder> orderes = glassOrderDao.findByLengthAndWidth(glass.getRawPackageTxt().getTxt_name(), glass.getApart_id(),glass.getLength(),glass.getWidth());
|
if (orderes.size()>0) {
|
GlassOrder order = orderes.get(0);
|
order.setDamagePieces(order.getDamagePieces()+1);
|
glassOrderDao.save(order);
|
}else {
|
List<GlassOrder> ors = glassOrderDao.findByLength(glass.getRawPackageTxt().getTxt_name(), glass.getLength(), glass.getWidth());
|
if (ors.size()>0) {
|
GlassOrder or = ors.get(0);
|
or.setDamagePieces(or.getDamagePieces()+1);
|
glassOrderDao.save(or);
|
}
|
}
|
}
|
|
//进片后破损
|
public void moreps(Glass glass){
|
List<GlassOrder> orderes = glassOrderDao.findByLengthAndWidth(glass.getRawPackageTxt().getTxt_name(), glass.getApart_id(),glass.getLength(),glass.getWidth());
|
if (orderes.size()>0) {
|
GlassOrder order = orderes.get(0);
|
order.setDamagePieces(order.getDamagePieces()+1);
|
glassOrderDao.save(order);
|
}else {
|
List<GlassOrder> ors = glassOrderDao.findByLength(glass.getRawPackageTxt().getTxt_name(), glass.getLength(), glass.getWidth());
|
if (ors.size()>0) {
|
GlassOrder or = ors.get(0);
|
or.setDamagePieces(or.getDamagePieces()+1);
|
glassOrderDao.save(or);
|
}
|
}
|
}
|
|
public String reviewglass(String id) {
|
TougheningGlass tougheningGlass = tougheningGlassDao.findOne(Long.parseLong(id));
|
if (tougheningGlass !=null) {
|
Glass glass = tougheningGlass.getGlass();
|
if (glass != null) {
|
glass.setCompletePieces(glass.getCompletePieces()-1);;
|
if (glass.getState().equals("已识别")) {
|
glass.setState("待识别");
|
}
|
glassDao.save(glass);
|
// tougheningGlass.setState("退回");
|
// tougheningGlassDao.save(tougheningGlass);
|
tougheningGlassDao.delete(tougheningGlass);
|
return "ok";
|
}else {
|
return "noglass";
|
}
|
}else {
|
return "noglass";
|
}
|
}
|
|
}
|