package com.northglass.service.device;
|
|
import java.io.File;
|
import java.io.FileInputStream;
|
import java.io.FileOutputStream;
|
import java.io.IOException;
|
import java.io.InputStreamReader;
|
import java.io.OutputStream;
|
import java.nio.charset.StandardCharsets;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.Enumeration;
|
import java.util.HashMap;
|
import java.util.List;
|
import java.util.Locale;
|
import java.util.Map;
|
import java.util.Properties;
|
|
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.MachineType;
|
import com.northglass.constants.StateConstants.LoadMachineRackState;
|
import com.northglass.constants.StateConstants.PrintMachineState;
|
import com.northglass.constants.StateConstants.RackState;
|
import com.northglass.constants.StateConstants.ShelfHoistState;
|
import com.northglass.constants.StateConstants.ShelfRankState;
|
import com.northglass.constants.StateConstants.sendGlassState;
|
import com.northglass.entity.CountMachine;
|
import com.northglass.entity.CutMachine;
|
import com.northglass.entity.DummyFixRack;
|
import com.northglass.entity.FilmRemoveMachine;
|
import com.northglass.entity.GaoliweiMachine;
|
import com.northglass.entity.Glass;
|
import com.northglass.entity.GlassCommer;
|
import com.northglass.entity.GlassNumberColor;
|
import com.northglass.entity.LoadMachine;
|
import com.northglass.entity.LoadMachineRack;
|
import com.northglass.entity.MachineStatu;
|
import com.northglass.entity.PrintMachine;
|
import com.northglass.entity.PrintName;
|
import com.northglass.entity.PrintSize;
|
import com.northglass.entity.RawPackage;
|
import com.northglass.entity.RawPackageTxt;
|
import com.northglass.entity.Shelf;
|
import com.northglass.entity.ShelfHoist;
|
import com.northglass.entity.ShelfRank;
|
import com.northglass.entity.ShelfStatu;
|
import com.northglass.entity.TestOut;
|
import com.northglass.listener.GMMSPrinter;
|
import com.northglass.repository.CountMachineDao;
|
import com.northglass.repository.DummyFixRackDao;
|
import com.northglass.repository.GaoliweiMachineDao;
|
import com.northglass.repository.GlassCommerDao;
|
import com.northglass.repository.GlassDao;
|
import com.northglass.repository.GlassNumberColorDao;
|
import com.northglass.repository.LoadMachineDao;
|
import com.northglass.repository.LoadMachineRackDao;
|
import com.northglass.repository.MachineStatuDao;
|
import com.northglass.repository.PrintMachineDao;
|
import com.northglass.repository.PrintNameDao;
|
import com.northglass.repository.PrintSizeDao;
|
import com.northglass.repository.RawPackageTxtDao;
|
import com.northglass.repository.ShelfDao;
|
import com.northglass.repository.ShelfHoistDao;
|
import com.northglass.repository.ShelfRankDao;
|
import com.northglass.repository.ShelfStatuDao;
|
import com.northglass.repository.TestOutDao;
|
import com.northglass.service.DownLie.DownLieMachineService;
|
import com.northglass.service.Liedown.LiedownMachineService;
|
import com.northglass.service.stackermachine.StackerMachineService;
|
import com.northglass.service.arrangemachine.ArrangeMachineService;
|
import com.northglass.service.chamfermachine.ChamferMachineService;
|
import com.northglass.service.countmachine.CountMachineService;
|
import com.northglass.service.cutmachine.CutMachineService;
|
import com.northglass.service.edgemachine.EdgeMachineService;
|
import com.northglass.service.filmremovemachine.FilmRemoveMachineService;
|
import com.northglass.service.gaoliwei.GaoliweiMachineService;
|
import com.northglass.service.identifymachine.IdentifyMachineService;
|
import com.northglass.service.loadmachine.LoadMachineService;
|
import com.northglass.service.measuremachine.MeasureMachineService;
|
import com.northglass.service.shelf.ShelfService;
|
import com.northglass.service.shelfmanager.ShelfManagerService;
|
import com.northglass.service.tidy.TidyMachineService;
|
import com.northglass.service.transfermachine.TransferMachineService;
|
import com.northglass.service.washmachine.WashMachineService;
|
import com.northglass.util.HexUtil;
|
import com.northglass.web.gaoliwei.GaoliweiController;
|
|
@Component
|
@Transactional
|
public class DeviceService {
|
|
private static final Logger LOGGER = LoggerFactory.getLogger(DeviceService.class);
|
|
@Autowired
|
private ShelfService shelfService;
|
|
@Autowired
|
private CutMachineService cutMachineService;
|
|
@Autowired
|
private LoadMachineService loadMachineService;
|
|
@Autowired
|
private FilmRemoveMachineService filmRemoveMachineService;
|
|
@Autowired
|
private ShelfRankDao shelfRankDao;
|
|
@Autowired
|
private GaoliweiMachineDao gaoliweiMachineDao;
|
|
@Autowired
|
private ShelfHoistDao shelfHoistDao;
|
|
@Autowired
|
private CountMachineDao countMachineDao;
|
|
@Autowired
|
private LoadMachineRackDao loadMachineRackDao;
|
|
@Autowired
|
private CountMachineService countMachineService;
|
|
@Autowired
|
private GaoliweiMachineService gaoliweiMachineService;
|
|
@Autowired
|
private ArrangeMachineService arrangeMachineService;
|
|
@Autowired
|
private MeasureMachineService measureMachineService;
|
|
@Autowired
|
private TestOutDao testOutDao;
|
|
@Autowired
|
private GlassNumberColorDao colorDao;
|
|
@Autowired
|
private RawPackageTxtDao rawPackageTxtDao;
|
|
@Autowired
|
private GlassDao glassDao;
|
|
@Autowired
|
private PrintSizeDao printSizeDao;
|
|
@Autowired
|
private PrintNameDao printNameDao;
|
|
@Autowired
|
private PrintMachineDao printMachineDao;
|
|
@Autowired
|
private ShelfStatuDao shelfStatuDao;
|
|
@Autowired
|
private DummyFixRackDao dummyFixRackDao;
|
|
@Autowired
|
private GlassCommerDao glassCommerDao;
|
|
@Autowired
|
private IdentifyMachineService identifyMachineService;
|
|
@Autowired
|
private LiedownMachineService liedownMachineService;
|
|
@Autowired
|
private DownLieMachineService downLieMachineService;
|
|
@Autowired
|
private StackerMachineService stackerMachineService;
|
|
@Autowired
|
private TidyMachineService tidyMachineService;
|
|
@Autowired
|
private EdgeMachineService edgeMachineService;
|
|
@Autowired
|
private TransferMachineService transferMachineService;
|
|
@Autowired
|
private WashMachineService washMachineService;
|
|
@Autowired
|
private ChamferMachineService chamferMachineService;
|
|
@Autowired
|
private LoadMachineService LoadMachineService;
|
|
@Autowired
|
private ShelfManagerService shelfManagerService;
|
|
@Autowired
|
private LoadMachineDao loadMachineDao;
|
|
public static String language="messages_vi_VN";
|
|
@Autowired
|
private ShelfDao shelfDao;
|
public void resetState() {
|
// shelfService.resetState();
|
// cutMachineService.resetState();
|
// loadMachineService.resetState();
|
// gaoliweiMachineService.resetState();
|
//identifyMachineService.resetState();
|
// edgeMachineService.resetState();
|
//washMachineService.resetState();
|
// filmRemoveMachineService.resetState();
|
//countMachineService.resetState();
|
// grindEdgeMachineService.resetState();
|
// grindEdgeMachineTwoService.resetState();
|
//arrangeMachineService.resetState();
|
//measureMachineService.resetState();
|
}
|
|
public void resetRankState() {
|
List<ShelfRank> shelfRankList = shelfRankDao.findAll();
|
for (ShelfRank rank : shelfRankList) {
|
rank.setState(ShelfRankState.FREE);
|
}
|
shelfRankDao.save(shelfRankList);
|
|
List<ShelfHoist> shelfHoistList = shelfHoistDao.findAll();
|
for (ShelfHoist hoist : shelfHoistList) {
|
hoist.setState(ShelfHoistState.FREE);
|
}
|
shelfHoistDao.save(shelfHoistList);
|
|
List<LoadMachineRack> loadMachineRackList = loadMachineRackDao.findAll();
|
for (LoadMachineRack rack : loadMachineRackList) {
|
rack.setState(LoadMachineRackState.FREE);
|
}
|
loadMachineRackDao.save(loadMachineRackList);
|
}
|
public void CeshiMainche() {
|
//List<Machine> Machine=machineDao.SelectMinchineFlag("1");
|
List<LoadMachine> loadMachineS=loadMachineDao.findAll();
|
LoadMachine loadMachine=loadMachineS.get(2);
|
String str="000000000000000000";
|
for(int i=0;i<45;i++){
|
if(i==0||i==999){
|
str+="0001";
|
}else{
|
str+="0000";
|
}
|
}
|
//String strss=shelfService.generateReturnMessage(str);
|
String strss=LoadMachineService.generateReturnMessage(str,loadMachine);
|
if(strss.length()>26){
|
System.out.println(loadMachine.getNumber()+"写入内容:"+strss.substring(26));
|
}else{
|
System.out.println("无");
|
}
|
}
|
public void connect() {
|
// CeshiMainche();
|
|
shelfService.connect();//仓储 1
|
loadMachineService.connect();//上片机 4
|
|
// cutMachineService.connect();//切割机 2
|
// liedownMachineService.connect();//立转卧 1
|
// downLieMachineService.connect();//卧转立 1
|
// stackerMachineService.connect();//堆高机 1
|
// transferMachineService.connect();//传送台 2
|
// gaoliweiMachineService.connect();//磨边端口1001
|
// edgeMachineService.connect();//磨边端口1002
|
|
|
|
//identifyMachineService.connect();//测量台
|
//chamferMachineService.connect();//倒角机
|
//countMachineService.connect();//下片打印程序
|
}
|
|
public List<Device> deviceManage() {
|
List<Device> deviceList = new ArrayList<Device>();
|
Shelf shelf = shelfService.getDefaultShelf();
|
if (shelf != null) {
|
Device shelfDevice = new Device(shelf.getId(), "原片仓储" + shelf.getNumber(), shelf.getPort(),
|
MachineType.SHELF);
|
deviceList.add(shelfDevice);
|
}
|
List<LoadMachine> loadMachines = loadMachineService.getAll();
|
for (LoadMachine loadMachine : loadMachines) {
|
Device loadMachineDevice = new Device(loadMachine.getId(), "上片机" + loadMachine.getNumber(),
|
loadMachine.getPort(), MachineType.LOAD_MACHINE);
|
deviceList.add(loadMachineDevice);
|
}
|
|
List<GaoliweiMachine> gaoliweiMachines = gaoliweiMachineDao.findAll();
|
for (GaoliweiMachine gaoliweiMachine : gaoliweiMachines) {
|
Device loadMachineDevice = new Device(gaoliweiMachine.getId(), "高力威" + gaoliweiMachine.getNumber(),
|
gaoliweiMachine.getPort(), MachineType.LOAD_MACHINE);
|
deviceList.add(loadMachineDevice);
|
}
|
List<CountMachine> countMachines = countMachineDao.findAll();
|
for (CountMachine countMachine : countMachines) {
|
Device loadMachineDevice = new Device(countMachine.getId(), "下片机" + countMachine.getNumber(),
|
countMachine.getPort(), MachineType.LOAD_MACHINE);
|
deviceList.add(loadMachineDevice);
|
}
|
return deviceList;
|
}
|
|
public void modifyPort(String type, Long id, int port) {
|
LOGGER.debug("> 开始定义");
|
LOGGER.debug("type: " + type);
|
LOGGER.debug("id: " + id);
|
LOGGER.debug("port: " + port);
|
|
if (type.equalsIgnoreCase(MachineType.SHELF)) {
|
Shelf shelf = shelfService.getDefaultShelf();
|
shelf.setPort(port);
|
shelfService.save(shelf);
|
} else if (type.equalsIgnoreCase(MachineType.LOAD_MACHINE)) {
|
LoadMachine loadMachine = loadMachineService.getById(id);
|
loadMachine.setPort(port);
|
loadMachineService.saveLoadMachine(loadMachine);
|
} else if (type.equalsIgnoreCase(MachineType.CUT_MACHINE)) {
|
CutMachine cutMachine = cutMachineService.getById(id);
|
cutMachine.setPort(port);
|
cutMachineService.save(cutMachine);
|
} else if (type.equalsIgnoreCase("filmremovemachine")) {
|
FilmRemoveMachine filmRemoveMachine = filmRemoveMachineService.getById(id);
|
filmRemoveMachine.setPort(port);
|
filmRemoveMachineService.save(filmRemoveMachine);
|
} else if (type.equalsIgnoreCase(MachineType.COUNT_MACHINE)) {
|
CountMachine countMachine = countMachineService.getById(id);
|
countMachine.setPort(port);
|
countMachineService.saveCountMachine(countMachine);
|
}
|
|
LOGGER.debug("> End modifyPort");
|
}
|
|
|
/****
|
* 根据word的数量得到每个信号
|
* @param Str
|
* @param count
|
* @return
|
*/
|
public String[] GetResultTexts(String Str,int count) {
|
String []InfoTex =new String[count];
|
for(int i=0;i<count;i++){
|
InfoTex[i]=Str.substring(0,4);
|
Str=Str.substring(4);
|
}
|
return InfoTex;
|
}
|
|
public Map<String, Object> getdropped() {
|
Map<String, Object> param = new HashMap<String, Object>();
|
List<TestOut> shelf = testOutDao.findByName("shelf");
|
List<TestOut> loadMachine01 = testOutDao.findByName("loadMachine01");
|
List<TestOut> loadMachine02 = testOutDao.findByName("loadMachine02");
|
List<TestOut> countMachine01 = testOutDao.findByName("countMachine01");
|
List<TestOut> countMachine02 = testOutDao.findByName("countMachine02");
|
List<TestOut> gaoliweiMachine01 = testOutDao.findByName("gaoliweiMachine01");
|
List<TestOut> gaoliweiMachine02 = testOutDao.findByName("gaoliweiMachine02");
|
param.put("shelf", shelf.size());
|
param.put("loadMachine01", loadMachine01.size());
|
param.put("loadMachine02", loadMachine02.size());
|
param.put("gaoliweiMachine01", gaoliweiMachine01.size());
|
param.put("gaoliweiMachine02", gaoliweiMachine02.size());
|
param.put("countMachine01", countMachine01.size());
|
param.put("countMachine02", countMachine02.size());
|
return param;
|
}
|
|
public void deletedrop() {
|
testOutDao.deleteAll();
|
}
|
|
public String findColorHtml() {
|
Map<String, Object> language=DeviceService.readLanguage();
|
StringBuffer html = new StringBuffer();
|
List<GlassNumberColor> colors = colorDao.findAll();
|
for (int i = 0; i < colors.size(); i++) {
|
GlassNumberColor color = colors.get(i);
|
html.append("<tr><td>").append(color.getId()).append("</td><td>");
|
html.append("<span class='label label-success'>").append(color.getGlassId());
|
html.append("</span></td><td><a href='/gmms2/device/deletecolor/").append(color.getId())
|
.append("' class='btn btn-danger'>"+language.get("delete").toString()+"</a></td></tr>");
|
}
|
return html.toString();
|
}
|
|
public void addcolor(GlassNumberColor color) {
|
color.setFlag("0");
|
colorDao.save(color);
|
}
|
|
public void deletecolor(String id) {
|
GlassNumberColor color = colorDao.findOne(Long.parseLong(id));
|
colorDao.delete(Long.parseLong(id));
|
LOGGER.debug("删除膜系" + color.getGlassId());
|
}
|
|
public void finish() {
|
GaoliweiController.setButton("1");
|
GaoliweiController.setButton1("1");
|
}
|
|
public void prints(String s) {
|
PrintMachine printMachin = printMachineDao.findByLine(s);
|
GMMSPrinter printer = new GMMSPrinter("罗兰测试1", "0100000463", "5mmXTY270镀膜不印标(异形)钢化",
|
"5-9 1816289-2 固玻 关埠 按图开介,图-1", "1L", 888, 666, "20181014.02A", "A", "12345", s, 1, (long) 123,
|
printMachin.getName(), printMachin.getStatu(), "4","归来出");
|
if (!s.equals("1")) {
|
printer = new GMMSPrinter("罗兰测试2", "0100000464", "5mmXTY270镀膜不印标(异形)钢化", "5-9 1816289-2 固玻 关埠 按图开介,图-1",
|
"1L", 1000, 800, "20181024.01A", "B", "33333", s, 1, (long) 123, printMachin.getName(),
|
printMachin.getStatu(), "4","归来去");
|
}
|
|
// 开始打印
|
printer.doPrint();
|
}
|
|
public void finishmo(String id) {
|
if (id.equals("1")) {
|
GaoliweiController.setButton("1");
|
LOGGER.debug("发送一号线清空指令");
|
} else {
|
GaoliweiController.setButton1("1");
|
LOGGER.debug("发送二号线清空指令");
|
}
|
}
|
|
|
|
|
// public static void WriteFile(String URL,String FileName,String Content){
|
// try {
|
// String FileUrl=URL+File.separator+FileName;
|
// File file=new File(FileUrl);
|
// if(file.exists()){
|
// file.createNewFile();
|
// }
|
// OutputStream out =new FileOutputStream(file,true);
|
// Content="\r"+Content;
|
// byte[] b=Content.getBytes();
|
// out.write(b);
|
// out.close();
|
// } catch (Exception e) {
|
// // TODO: handle exception
|
// }
|
// }
|
|
|
|
|
public void again(String id) {
|
RawPackageTxt rawPackageTxt = rawPackageTxtDao.findAcceptedByGroup("1");
|
if (rawPackageTxt == null) {
|
LOGGER.debug("没有任务,不处理信息");
|
} else {
|
String txtName = rawPackageTxt.getTxt_name();
|
List<Glass> allGlasses = glassDao.findByBatch(txtName);
|
if (allGlasses.size() > 0) {
|
if (id.equals("1")) {
|
for (Glass glass : allGlasses) {
|
glass.setSendState(sendGlassState.NOTSEND);
|
glassDao.save(glass);
|
}
|
} else if (id.equals("2")) {
|
for (Glass glass : allGlasses) {
|
glass.setSendStates(sendGlassState.NOTSEND);
|
glassDao.save(glass);
|
}
|
}
|
}
|
}
|
|
}
|
|
public void nosend(String id) {
|
RawPackageTxt rawPackageTxt = rawPackageTxtDao.findAcceptedByGroup("1");
|
if (rawPackageTxt == null) {
|
LOGGER.debug("没有任务,不处理信息");
|
} else {
|
String txtName = rawPackageTxt.getTxt_name();
|
List<Glass> allGlasses = glassDao.findByBatch(txtName);
|
if (allGlasses.size() > 0) {
|
if (id.equals("1")) {
|
for (Glass glass : allGlasses) {
|
glass.setSendState(sendGlassState.NOTUSE);
|
glassDao.save(glass);
|
}
|
} else if (id.equals("2")) {
|
for (Glass glass : allGlasses) {
|
glass.setSendStates(sendGlassState.NOTUSE);
|
glassDao.save(glass);
|
}
|
}
|
}
|
}
|
}
|
|
public PrintSize findPrintSize() {
|
return printSizeDao.findOne(1L);
|
}
|
|
public PrintName findPrintName(Long s) {
|
return printNameDao.findOne(s);
|
}
|
|
public String getPrintHtml(long l) {
|
StringBuffer html = new StringBuffer();
|
List<PrintMachine> printMachines = printMachineDao.findAll();
|
if (printMachines.size() > 0) {
|
for (PrintMachine printMachine : printMachines) {
|
html.append("<tr><td>打印机").append(printMachine.getLine()).append("</td>");
|
html.append("<td>");
|
if (printMachine.getPattern().equals(PrintMachineState.PATTERN_SINGLE)) {
|
html.append("单片打印");
|
} else if (printMachine.getPattern().equals(PrintMachineState.PATTERN_ALL)) {
|
html.append("全部打印");
|
} else {
|
html.append("不打印");
|
}
|
html.append("</td>");
|
html.append("<td>").append(printMachine.getStatu()).append("</td>");
|
html.append("<td><a class='btn btn-large btn-success' onclick='modifypattern(")
|
.append(printMachine.getId()).append(")'>修改打印类型</a>");
|
html.append("<a class='btn btn-large btn-success' onclick='modifystatu(").append(printMachine.getId())
|
.append(")'>修改打印属性</a>");
|
html.append("<a class='btn btn-large btn-success' href='/gmms2/device/print/")
|
.append(printMachine.getId()).append("'>打印测试</a>");
|
html.append("</td></tr>");
|
}
|
}
|
html.append("</tr>");
|
return html.toString();
|
}
|
|
public void modifyPattern(PrintMachine printMachine) {
|
// String line = printMachine.getLine();
|
|
String s = "";
|
PrintMachine print = printMachineDao.findByLine(printMachine.getLine());
|
if (printMachine.getPattern().equals("单片打印")) {
|
s = PrintMachineState.PATTERN_SINGLE;
|
} else if (printMachine.getPattern().equals("全部打印")) {
|
s = PrintMachineState.PATTERN_ALL;
|
} else {
|
s = PrintMachineState.PATTERN_NOT;
|
}
|
print.setPattern(s);
|
printMachineDao.save(print);
|
}
|
|
public void modifyStatu(PrintMachine printMachine) {
|
PrintMachine print = printMachineDao.findByLine(printMachine.getLine());
|
print.setStatu(printMachine.getStatu());
|
printMachineDao.save(print);
|
}
|
|
public String getstatu() {
|
StringBuffer html = new StringBuffer();
|
|
return html.toString();
|
}
|
|
/**
|
* 仓储信息
|
*
|
* @author 司家旺
|
*
|
**/
|
public String getshelfstatu() {
|
StringBuffer html = new StringBuffer();
|
List<ShelfStatu> status = shelfStatuDao.findAll();
|
if (status.size() > 0) {
|
for (ShelfStatu statu : status) {
|
html.append("<tr style='color:red'><td>").append(statu.getId()).append("</td>");
|
html.append("<td>").append(statu.getAutostate()).append("</td>");
|
html.append("<td>").append(statu.getErrorstate()).append("</td>");
|
html.append("<td>").append(statu.getPlcid()).append("</td>");
|
html.append("<td>").append(statu.getMesid()).append("</td>");
|
html.append("<td>").append(statu.getSetTime()).append("</td></tr>");
|
}
|
}
|
return html.toString();
|
}
|
|
public String getloadstatu() {
|
StringBuffer html = new StringBuffer();
|
ShelfStatu statu = shelfStatuDao.findByMachine("load");
|
if (statu != null) {
|
html.append("<tr style='color:red'><td>").append(statu.getId()).append("</td>");
|
html.append("<td>").append(statu.getAutostate()).append("</td>");
|
html.append("<td>").append(statu.getErrorstate()).append("</td>");
|
html.append("<td>").append(statu.getLoadfinish()).append("</td>");
|
html.append("<td>").append(statu.getPlcid()).append("</td>");
|
html.append("<td>").append(statu.getMesid()).append("</td>");
|
html.append("<td>").append(statu.getSetTime()).append("</td></tr>");
|
}
|
return html.toString();
|
}
|
|
public String getgaoliweistatu() {
|
StringBuffer html = new StringBuffer();
|
ShelfStatu statu = shelfStatuDao.findByMachine("gaoliwei");
|
if (statu != null) {
|
html.append("<tr style='color:red;'><td>").append(statu.getId()).append("</td>");
|
html.append("<td>").append(statu.getAutostate()).append("</td>");
|
html.append("<td>").append(statu.getLoadfinish()).append("</td>");
|
html.append("<td>").append(statu.getPlcid()).append("</td>");
|
html.append("<td>").append(statu.getMesid()).append("</td>");
|
html.append("<td>").append(statu.getSetTime()).append("</td></tr>");
|
}
|
return html.toString();
|
}
|
|
public String serchglass(String name) {
|
StringBuffer html = new StringBuffer();
|
LOGGER.debug("name:" + name);
|
List<Glass> glasses = glassDao.findByBatch(name);
|
LOGGER.debug("glasses:" + glasses.size());
|
if (glasses.size() > 0) {
|
for (Glass glass : glasses) {
|
if (glass.getPieces() == glass.getCompletePieces()) {
|
html.append("<tr>");
|
} else {
|
html.append("<tr style='color:red'>");
|
}
|
html.append("<td>").append(glass.getId()).append("</td>");
|
html.append("<td>").append(glass.getManufacture_batch()).append("</td>");
|
html.append("<td>").append(glass.getLength()).append("</td>");
|
html.append("<td>").append(glass.getWidth()).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>")
|
.append("<a type='button' class='btn btn-large btn-success' href='/gmms2/device/printglass/")
|
.append(glass.getId());
|
html.append(
|
"/1'>打印1</a><a type='button' class='btn btn-large btn-success' href='/gmms2/device/printglass/")
|
.append(glass.getId());
|
html.append("/2'>打印2</a>");
|
html.append("</td></tr>");
|
}
|
}
|
return html.toString();
|
}
|
|
public String workglass() {
|
StringBuffer html = new StringBuffer();
|
RawPackageTxt txt = rawPackageTxtDao.findCutFinishByGroup("1");
|
if (txt == null) {
|
txt = rawPackageTxtDao.findAcceptedByGroup("1");
|
}
|
if (txt != null) {
|
List<Glass> glasses = glassDao.findByBatch(txt.getTxt_name());
|
|
if (glasses.size() > 0) {
|
for (Glass glass : glasses) {
|
if (glass.getPieces() == glass.getCompletePieces()) {
|
html.append("<tr>");
|
} else {
|
html.append("<tr style='color:red'>");
|
}
|
html.append("<td>").append(glass.getId()).append("</td>");
|
html.append("<td>").append(glass.getManufacture_batch()).append("</td>");
|
html.append("<td>").append(glass.getLength()).append("</td>");
|
html.append("<td>").append(glass.getWidth()).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>")
|
.append("<a type='button' class='btn btn-large btn-success' href='/gmms2/device/printglass/")
|
.append(glass.getId());
|
html.append(
|
"/1'>打印1</a><a type='button' class='btn btn-large btn-success' href='/gmms2/device/printglass/")
|
.append(glass.getId());
|
html.append("/2'>打印2</a></td>");*/
|
html.append("</tr>");
|
}
|
}
|
}
|
return html.toString();
|
}
|
|
public void printglass(String id, String line) {
|
Glass glass = glassDao.findOne(Long.valueOf(id));
|
PrintMachine printMachin = printMachineDao.findByLine(line);
|
if (glass != null) {
|
new GMMSPrinter(glass.getCustomer(), glass.getApplication(), glass.getProduction(), glass.getFloor_number(),
|
glass.getOrder_number(), glass.getLength(), glass.getWidth(), glass.getApart_id(),
|
glass.getPiece_sign(), glass.getRemark(), line, glass.getPieces(), 1L, printMachin.getName(),
|
printMachin.getStatu(), glass.getArrangeStatu(),glass.getThingsout()).doPrint();
|
}
|
}
|
|
public void otherprint(String id) {
|
|
PrintMachine printMachin = printMachineDao.findByLine(id);
|
RawPackageTxt txt = rawPackageTxtDao.findCutFinishByGroup("1");
|
if (txt == null) {
|
txt = rawPackageTxtDao.findAcceptedByGroup("1");
|
}
|
LOGGER.debug("打印剩余的玻璃标签!");
|
if (txt != null) {
|
List<Glass> glasses = glassDao.findByBatch(txt.getTxt_name());
|
if (glasses.size() > 0) {
|
for (Glass glass : glasses) {
|
if (glass.getPieces() > glass.getCompletePieces()) {
|
for (int i = 0; i < glass.getPieces() - glass.getCompletePieces(); i++) {
|
new GMMSPrinter(glass.getCustomer(), glass.getApplication(), glass.getProduction(),
|
glass.getFloor_number(), glass.getOrder_number(), glass.getLength(),
|
glass.getWidth(), glass.getApart_id(), glass.getPiece_sign(), glass.getRemark(),
|
id, glass.getPieces(), 1L, printMachin.getName(), printMachin.getStatu(),
|
glass.getArrangeStatu(),glass.getThingsout()).doPrint();
|
}
|
glass.setCompletePieces(glass.getPieces());
|
glassDao.save(glass);
|
}
|
|
}
|
}
|
}
|
|
}
|
|
/**
|
*
|
* @author northglass
|
* 功能:获得虚拟料架的专属列表
|
* 2019年3月18日
|
*
|
* **/
|
public String getdummyhtml() {
|
StringBuffer html = new StringBuffer();
|
List<DummyFixRack> dummyFixRacks = dummyFixRackDao.findAll();
|
if (dummyFixRacks.size()>0) {
|
for (DummyFixRack dummyFixRack :dummyFixRacks) {
|
html.append("<tr><td>").append(dummyFixRack.getNumber()).append("</td><td>");
|
if (dummyFixRack.getState().equals(RackState.FREE)) {
|
html.append(dummyFixRack.getState()).append("</td><td>");
|
html.append("<button class=\"btn btn-large btn-success\" onclick=\"addrack(").append(dummyFixRack.getId()).append(")\">添加原片</button>");
|
}else {
|
html.append("【").append(dummyFixRack.getThickness()).append("mm").append(dummyFixRack.getWidth());
|
html.append("*"+dummyFixRack.getHeight() + " mm " +dummyFixRack.getColor()+ "】");
|
html.append(dummyFixRack.getLeftPieces()+"/"+dummyFixRack.getPieces()).append("</td><td>");
|
html.append("<button class=\"btn btn-large btn-warning\" onclick=\"modifyrack(").append(dummyFixRack.getId()).append(")\">修改原片</button> ");
|
html.append("<a class=\"btn btn-large btn-danger\" href=\"/gmms2/device/deleteDummyRack/").append(dummyFixRack.getId()).append("\">删除原片</a>");
|
}
|
html.append("</td></tr>");
|
}
|
}
|
return html.toString();
|
}
|
|
/***
|
*
|
* @author northglass
|
* 2019年3月18日
|
* 功能:删除虚拟料架上面的数据
|
*
|
* **/
|
public void deleteDummyRack(String id) {
|
DummyFixRack dummyFixRack = dummyFixRackDao.findOne(Long.parseLong(id));
|
if (dummyFixRack != null) {
|
dummyFixRack.setColor(null);
|
dummyFixRack.setHeight(0);
|
dummyFixRack.setThickness(0);
|
dummyFixRack.setWidth(0);
|
dummyFixRack.setLeftPieces(0);
|
dummyFixRack.setPieces(0);
|
dummyFixRack.setState(RackState.FREE);
|
dummyFixRackDao.save(dummyFixRack);
|
}
|
}
|
|
/***
|
*
|
* @author northglass
|
* 2019年3月18日
|
* 功能:修改虚拟料架里面的片数
|
*
|
* **/
|
public void modifyRack(String pieces, String ids) {
|
DummyFixRack dummyFixRack = dummyFixRackDao.findOne(Long.parseLong(ids));
|
int pic = Integer.parseInt(pieces);
|
if (pic == 0) {
|
dummyFixRack.setColor(null);
|
dummyFixRack.setHeight(0);
|
dummyFixRack.setThickness(0);
|
dummyFixRack.setWidth(0);
|
dummyFixRack.setLeftPieces(0);
|
dummyFixRack.setPieces(0);
|
dummyFixRack.setState(RackState.FREE);
|
}else {
|
dummyFixRack.setLeftPieces(pic);
|
}
|
dummyFixRackDao.save(dummyFixRack);
|
}
|
|
/***
|
*
|
* @author northglass
|
* 2019年3月18日
|
* 功能:添加虚拟料架上面的信息
|
*
|
* **/
|
public void addRack(RawPackage rawPackage, String shelfRankNumber, String ids) {
|
DummyFixRack dummyFixRack = dummyFixRackDao.findOne(Long.parseLong(ids));
|
if (dummyFixRack !=null ) {
|
dummyFixRack.setColor(rawPackage.getColor());
|
dummyFixRack.setHeight(rawPackage.getHeight());
|
dummyFixRack.setWidth(rawPackage.getWidth());
|
dummyFixRack.setThickness(rawPackage.getThickness());
|
dummyFixRack.setPieces(rawPackage.getPieces());
|
dummyFixRack.setLeftPieces(dummyFixRack.getPieces());
|
dummyFixRack.setState(RackState.IN_WORK);
|
dummyFixRack.setCreateTime(new Date());
|
dummyFixRackDao.save(dummyFixRack);
|
}
|
}
|
|
/**
|
*
|
* @author northglass
|
* 功能:获得查询虚拟料架的专属列表
|
* 2019年3月19日
|
*
|
* **/
|
|
public String getserachdummyhtml(String color, String glassThickness) {
|
StringBuffer html = new StringBuffer();
|
List<DummyFixRack> dummyFixRacks = dummyFixRackDao.findbyColorAndThickness(color,Double.parseDouble(glassThickness));
|
if (dummyFixRacks.size()>0) {
|
for (DummyFixRack dummyFixRack :dummyFixRacks) {
|
html.append("<tr><td>").append(dummyFixRack.getNumber()).append("</td><td>");
|
if (dummyFixRack.getState().equals(RackState.FREE)) {
|
html.append(dummyFixRack.getState()).append("</td><td>");
|
html.append("<button class=\"btn btn-large btn-success\" onclick=\"addrack(").append(dummyFixRack.getId()).append(")\">添加原片</button>");
|
}else {
|
html.append("【").append(dummyFixRack.getThickness()).append("mm").append(dummyFixRack.getWidth());
|
html.append("*"+dummyFixRack.getHeight() + " mm " +dummyFixRack.getColor()+ "】");
|
html.append(dummyFixRack.getLeftPieces()+"/"+dummyFixRack.getPieces()).append("</td><td>");
|
html.append("<button class=\"btn btn-large btn-warning\" onclick=\"modifyrack(").append(dummyFixRack.getId()).append(")\">修改原片</button> ");
|
html.append("<a class=\"btn btn-large btn-danger\" href=\"/gmms2/device/deleteDummyRack/").append(dummyFixRack.getId()).append("\">删除原片</a>");
|
}
|
html.append("</td></tr>");
|
}
|
}
|
return html.toString();
|
}
|
|
public String findglasscumtorHtml() {
|
StringBuffer html = new StringBuffer();
|
List<GlassCommer> glassCommers = glassCommerDao.findAll();
|
for (int i = 0; i < glassCommers.size(); i++) {
|
GlassCommer glassCommer = glassCommers.get(i);
|
html.append("<tr><td>").append(glassCommer.getId()).append("</td><td>");
|
html.append("<span class='label label-success'>").append(glassCommer.getName());
|
html.append("</span></td><td><a href='/gmms2/device/deletecumtor/").append(glassCommer.getId())
|
.append("' class='btn btn-danger'>删除</a></td></tr>");
|
}
|
return html.toString();
|
}
|
|
public void addcommer(GlassCommer glassCommer) {
|
glassCommerDao.save(glassCommer);
|
}
|
|
public void deletecumtor(String id) {
|
GlassCommer glassCommer = glassCommerDao.findOne(Long.parseLong(id));
|
glassCommerDao.delete(Long.parseLong(id));
|
LOGGER.debug("删除膜系" + glassCommer.getName());
|
|
}
|
|
public Map<String, Object> getCeliangManageData(String groups) {
|
|
// Long machineId = Long.valueOf(groups);
|
Map<String, Object> param = new HashMap<String, Object>();
|
|
|
int totalPieces = 0;
|
int completePieces = 0;
|
|
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 static Map<String, Object> readLanguage(){
|
Map<String, Object> result=new HashMap<String, Object>();
|
//String url="D:\\Mes\\gmms_ynyk\\src\\main\\resources";
|
String url="D:\\Mes";
|
try {
|
if("messages_vi_VN".equals(DeviceService.language)){
|
result=propertiesToMapByAbsolutePath(url,"messages", new Locale("vi", "VN"));
|
}else if("messages_zh_CN".equals(DeviceService.language)){
|
result=propertiesToMapByAbsolutePath(url,"messages", Locale.SIMPLIFIED_CHINESE);
|
}
|
} catch (Exception e) {
|
// TODO: handle exception
|
}
|
return result;
|
}
|
|
/**
|
* 读取绝对路径下的 properties 文件,转换为 Map<String, Object>
|
* @param absolutePathPrefix 绝对路径前缀(如 "D:/i18n/" 或 "/usr/local/i18n/")
|
* @param basename 资源包前缀(如 "messages",对应文件名前缀)
|
* @param locale 语言标识(如 Locale.SIMPLIFIED_CHINESE)
|
* @return 键值对 Map
|
*/
|
public static Map<String, Object> propertiesToMapByAbsolutePath(
|
String absolutePathPrefix,
|
String basename,
|
Locale locale) {
|
|
Map<String, Object> resultMap = new HashMap<>();
|
Properties properties = new Properties();
|
|
// 1. 拼接完整绝对路径(处理路径分隔符,兼容 Windows/Linux)
|
// 路径分隔符:Windows 用 \,Linux 用 /,Java 中可统一用 /,或通过 File.separator 自动适配
|
String fileName = basename + "_" + locale.getLanguage() + "_" + locale.getCountry() + ".properties";
|
// 拼接前缀和文件名,确保路径分隔符正确(避免出现 "D:/i18n//messages_xxx.properties" 双斜杠,不影响读取)
|
String absoluteFilePath = absolutePathPrefix + File.separator + fileName;
|
// 可选:标准化路径(自动处理双斜杠、../ 等)
|
try {
|
absoluteFilePath = new File(absoluteFilePath).getCanonicalPath();
|
} catch (IOException e1) {
|
// TODO Auto-generated catch block
|
e1.printStackTrace();
|
}
|
// 2. 用 FileInputStream 读取本地绝对路径文件
|
try (FileInputStream fileInputStream = new FileInputStream(absoluteFilePath)) {
|
// 3. 验证文件是否存在(FileInputStream 找不到文件会抛 FileNotFoundException,这里提前判断更友好)
|
File propertiesFile = new File(absoluteFilePath);
|
if (!propertiesFile.exists()) {
|
throw new RuntimeException("未找到绝对路径下的资源文件:" + absoluteFilePath);
|
}
|
if (!propertiesFile.isFile()) {
|
throw new RuntimeException("路径不是文件:" + absoluteFilePath);
|
}
|
|
// 4. UTF-8 编码读取,解决中文乱码
|
properties.load(new InputStreamReader(fileInputStream, StandardCharsets.UTF_8));
|
|
// 5. 遍历转换为 Map
|
for (Enumeration<?> keys = properties.propertyNames(); keys.hasMoreElements(); ) {
|
String key = (String) keys.nextElement();
|
String value = properties.getProperty(key);
|
resultMap.put(key, value);
|
}
|
|
} catch (IOException e) {
|
e.printStackTrace();
|
throw new RuntimeException("读取绝对路径 properties 文件失败:" + e.getMessage() + ",文件路径:" + absoluteFilePath);
|
}
|
|
return resultMap;
|
}
|
public static void WriteFile(String URL,String FileName,String Content){
|
try {
|
String FileUrl=URL+File.separator+FileName;
|
File file=new File(FileUrl);
|
if(file.exists()){
|
file.createNewFile();
|
}
|
OutputStream out =new FileOutputStream(file,true);
|
Content="\r"+Content;
|
byte[] b=Content.getBytes();
|
out.write(b);
|
out.close();
|
} catch (Exception e) {
|
// TODO: handle exception
|
}
|
}
|
}
|