@ -11,7 +11,10 @@ import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.fastjson.JSON ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import com.spire.xls.CellRange ;
import com.spire.xls.PageSetup ;
import com.spire.xls.Workbook ;
import com.spire.xls.Worksheet ;
import lombok.RequiredArgsConstructor ;
import lombok.extern.slf4j.Slf4j ;
import org.nl.acs.device_driver.hailiang.hailiang_feeding_trunk.HaiLiangFeedingTrunkDeviceDriver ;
@ -37,10 +40,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional ;
import javax.servlet.http.HttpServletResponse ;
import java.awt.print.PageFormat ;
import java.awt.print.Paper ;
import java.awt.print.PrinterException ;
import java.awt.print.PrinterJob ;
import java.awt.print.* ;
import java.io.IOException ;
import java.util.* ;
@ -71,7 +71,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
}
public synchronized void reload ( ) {
this . order = this . queryAllOrder ( "(order_status !='07' and order_status !='08' and order_status !='09') and is_deleted =0" ) ;
order = this . queryAllOrder ( "(order_status !='07' and order_status !='08' and order_status !='09') and is_deleted =0" ) ;
produceshiftorderdetailService . reload ( ) ;
}
@ -335,6 +335,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
if ( ! StrUtil . equals ( dto . getOrder_id ( ) , "07" ) & & ! StrUtil . equals ( dto . getOrder_id ( ) , "08" ) & & ! StrUtil . equals ( dto . getOrder_id ( ) , "09" ) ) {
order . add ( dto ) ;
}
produceshiftorderdetailService . reload ( ) ;
}
@Override
@ -485,9 +486,23 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
WQLObject wo = WQLObject . getWQLObject ( "acs_produceshiftorder" ) ;
JSONObject json = ( JSONObject ) JSONObject . toJSON ( entity ) ;
wo . update ( json ) ;
HashMap < String , String > map = new HashMap < > ( ) ;
map . put ( "order_detail_status" , "07" ) ;
WQLObject . getWQLObject ( "acs_produceshiftorderdetail" ) . update ( map , "order_id = '" + id + "'" ) ;
// HashMap<String, String> map = new HashMap<>();
// map.put("order_detail_status","07");
// WQLObject.getWQLObject("acs_produceshiftorderdetail").update(map,"order_id = '"+ id + "'");
produceshiftorderdetailService . upodateDetailStatus ( entity . getOrder_code ( ) , "05" ) ;
Iterator < ProduceshiftorderDto > iterator = order . iterator ( ) ;
while ( iterator . hasNext ( ) ) {
ProduceshiftorderDto produceshiftorderDto = iterator . next ( ) ;
if ( produceshiftorderDto . getOrder_id ( ) . equals ( entity . getOrder_id ( ) ) ) {
iterator . remove ( ) ;
}
}
if ( ! StrUtil . equals ( entity . getOrder_id ( ) , "07" ) & & ! StrUtil . equals ( entity . getOrder_id ( ) , "08" ) & & ! StrUtil . equals ( entity . getOrder_id ( ) , "09" ) ) {
order . add ( entity ) ;
}
produceshiftorderdetailService . reload ( ) ;
}
@ -551,12 +566,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
List < HaiLiangFeedingTrunkDeviceDriver > deviceAll = deviceAppService . findDeviceDriver ( HaiLiangFeedingTrunkDeviceDriver . class ) ;
if ( deviceAll . get ( 0 ) instanceof HaiLiangFeedingTrunkDeviceDriver ) {
haiLiangFeedingTrunkDeviceDriver = ( HaiLiangFeedingTrunkDeviceDriver ) deviceAll . get ( 0 ) ;
if ( haiLiangFeedingTrunkDeviceDriver . getMode ( ) ! = 2 ) {
throw new BadRequestException ( "设备未联机,无法下发恢复!" ) ;
}
if ( haiLiangFeedingTrunkDeviceDriver . getPause ( ) = = 0 ) {
throw new BadRequestException ( "设备已处于恢复状态,无法下发恢复!" ) ;
}
haiLiangFeedingTrunkDeviceDriver . writing ( "to_pause" , "0" ) ;
}
}
@ -568,10 +577,6 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
List < HaiLiangFeedingTrunkDeviceDriver > deviceAll = deviceAppService . findDeviceDriver ( HaiLiangFeedingTrunkDeviceDriver . class ) ;
if ( deviceAll . get ( 0 ) instanceof HaiLiangFeedingTrunkDeviceDriver ) {
haiLiangFeedingTrunkDeviceDriver = ( HaiLiangFeedingTrunkDeviceDriver ) deviceAll . get ( 0 ) ;
if ( haiLiangFeedingTrunkDeviceDriver . getMode ( ) ! = 2 ) {
throw new BadRequestException ( "设备未联机,无法下发恢复!" ) ;
}
haiLiangFeedingTrunkDeviceDriver . writing ( "to_pause" , "1" ) ;
}
}
@ -601,6 +606,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
throw new BadRequestException ( "未找到对应工单明细!" ) ;
}
if ( ObjectUtil . isEmpty ( dto ) ) {
throw new BadRequestException ( "未找到对应工单!" ) ;
}
// 2.根据明细template_id 找到对应的模板
JSONObject jsonStor = WQL . getWO ( "QPRODUCESHIFTORDER" ) . addParam ( "flag" , "3" ) . addParam ( "storage_id" , detaildto . getTemplate_id ( ) ) . process ( ) . uniqueResult ( 0 ) ;
@ -636,8 +644,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
jo . put ( "inspector" , detaildto . getInspector ( ) ) ;
jo . put ( "mg_weight" , detaildto . getMg_weight ( ) ) ;
//打印纸张大小
jo . put ( "page_length" , "50" ) ;
jo . put ( "page_height" , "40" ) ;
//1cm = 118px
jo . put ( "page_length" , 590 ) ;
jo . put ( "page_height" , 472 ) ;
print ( jo ) ;
}
@ -753,6 +762,22 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
}
@Override
public void manual_finish ( Map whereJson ) {
String order = whereJson . get ( "parent_order_code" ) . toString ( ) ;
String detail = whereJson . get ( "order_code" ) . toString ( ) ;
ProduceshiftorderdetailDto detaildto = produceshiftorderdetailService . findOrderDetailFromCache ( order , detail ) ;
if ( ObjectUtil . isEmpty ( detaildto ) ) {
throw new BadRequestException ( "未找到对应工单明细!" ) ;
}
detaildto . setOrder_detail_status ( "05" ) ;
HaiLiangFeedingTrunkDeviceDriver haiLiangFeedingTrunkDeviceDriver ;
List < HaiLiangFeedingTrunkDeviceDriver > deviceAll = deviceAppService . findDeviceDriver ( HaiLiangFeedingTrunkDeviceDriver . class ) ;
produceshiftorderdetailService . update ( detaildto ) ;
}
@Override
public void download ( List < ProduceshiftorderDto > dtos , HttpServletResponse response ) throws IOException {
List < Map < String , Object > > list = new ArrayList < > ( ) ;
@ -863,7 +888,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
@Override
public List < ProduceshiftorderDto > findOrderByOrderStatusFromCache ( String order_status ) {
List < ProduceshiftorderDto > list = new ArrayList < ProduceshiftorderDto > ( ) ;
Iterator var3 = order . iterator ( ) ;
Iterator var3 = this . order . iterator ( ) ;
while ( var3 . hasNext ( ) ) {
ProduceshiftorderDto oneorder = ( ProduceshiftorderDto ) var3 . next ( ) ;
if ( StrUtil . equals ( oneorder . getOrder_status ( ) , order_status ) ) {
@ -1009,23 +1034,44 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
workBook . fill ( map , sheet ) ;
workBook . finish ( ) ;
// 5.打印
Workbook workbook = new Workbook ( ) ;
workbook . loadFromFile ( pathName ) ;
//创建 PrinterJob对象
PrinterJob printerJob = PrinterJob . getPrinterJob ( ) ;
//指定打印页面为默认大小和方向
PageFormat pageFormat = printerJob . defaultPage ( ) ;
//设置相关打印选项
Paper paper = pageFormat . getPaper ( ) ;
paper . setSize ( whereJson . getInteger ( "page_length" ) , whereJson . getInteger ( "page_height" ) ) ;
paper . setImageableArea ( 0 , 0 , whereJson . getInteger ( "page_length" ) , whereJson . getInteger ( "page_height" ) ) ;
pageFormat . setPaper ( paper ) ;
printerJob . setCopies ( 1 ) ;
printerJob . setPrintable ( workbook , pageFormat ) ;
Book book = new Book ( ) ;
Workbook loDoc = new Workbook ( ) ;
loDoc . loadFromFile ( pathName ) ;
Worksheet worksheet = loDoc . getWorksheets ( ) . get ( 0 ) ;
PageSetup pageSetup = worksheet . getPageSetup ( ) ;
String printArea = "A2:B8" ;
pageSetup . setPrintArea ( printArea ) ;
pageSetup . setLeftMargin ( 0 ) ;
pageSetup . setRightMargin ( 0 ) ;
pageSetup . setTopMargin ( 0 ) ;
pageSetup . setBottomMargin ( 0 ) ;
CellRange cellRanges = worksheet . getCellRange ( printArea ) ;
int height = 0 ;
for ( CellRange row : cellRanges . getRows ( ) ) {
height + = worksheet . getRowHeightPixels ( row . getRow ( ) ) ;
}
int width = 0 ;
for ( CellRange column : cellRanges . getColumns ( ) ) {
width + = worksheet . getColumnWidthPixels ( column . getColumn ( ) ) ;
}
PrinterJob loPrinterJob = PrinterJob . getPrinterJob ( ) ;
PageFormat loPageFormat = loPrinterJob . defaultPage ( ) ;
Paper loPaper = loPageFormat . getPaper ( ) ;
loPaper . setImageableArea ( 0 , 0 , loPageFormat . getWidth ( ) , loPageFormat . getHeight ( ) ) ;
loPaper . setSize ( 142 , 113 ) ;
// loPaper.setSize(width/96.0*72,height/96.0*72);
loPageFormat . setPaper ( loPaper ) ;
loPrinterJob . setCopies ( 1 ) ;
loPrinterJob . setPrintable ( loDoc , loPageFormat ) ;
book . append ( loDoc , loPageFormat ) ;
loPrinterJob . setPageable ( book ) ;
try {
// 执行打印
printerJob . print ( ) ;
loP rinterJob. print ( ) ;
} catch ( PrinterException e ) {
e . printStackTrace ( ) ;
return false ;
@ -1033,4 +1079,9 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A
return true ;
}
@Override
public List < ProduceshiftorderDto > findAllOrderFromCache ( ) {
return order ;
}
}