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