|
@ -6,9 +6,12 @@ import cn.hutool.core.util.IdUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import cn.hutool.core.util.StrUtil; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
|
|
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.Workbook; |
|
|
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; |
|
@ -33,6 +36,10 @@ 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.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.*; |
|
|
|
|
|
|
|
@ -417,6 +424,8 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A |
|
|
String labeling_template = jsonObject.getString("labeling_template"); |
|
|
String labeling_template = jsonObject.getString("labeling_template"); |
|
|
//优先级
|
|
|
//优先级
|
|
|
String priority = jsonObject.getString("priority"); |
|
|
String priority = jsonObject.getString("priority"); |
|
|
|
|
|
//优先级
|
|
|
|
|
|
String template_id = jsonObject.getString("template_id"); |
|
|
|
|
|
|
|
|
ProduceshiftorderdetailDto detaildto = new ProduceshiftorderdetailDto(); |
|
|
ProduceshiftorderdetailDto detaildto = new ProduceshiftorderdetailDto(); |
|
|
detaildto.setOrder_id(order_id); |
|
|
detaildto.setOrder_id(order_id); |
|
@ -442,6 +451,7 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A |
|
|
detaildto.setLettering_icon(lettering_icon); |
|
|
detaildto.setLettering_icon(lettering_icon); |
|
|
detaildto.setStrap_number(strap_number); |
|
|
detaildto.setStrap_number(strap_number); |
|
|
detaildto.setStrap_tailint_number(strap_tailint_number); |
|
|
detaildto.setStrap_tailint_number(strap_tailint_number); |
|
|
|
|
|
detaildto.setTemplate_id(template_id); |
|
|
produceshiftorderdetailService.create(detaildto); |
|
|
produceshiftorderdetailService.create(detaildto); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -860,4 +870,54 @@ public class ProduceshiftorderServiceImpl implements ProduceshiftorderService, A |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void print(JSONObject whereJson) { |
|
|
|
|
|
String order_id = whereJson.getString("order_id"); |
|
|
|
|
|
String template_id = whereJson.getString("template_id"); |
|
|
|
|
|
|
|
|
|
|
|
WQLObject mst = WQLObject.getWQLObject("acs_produceshiftorder"); // 主表
|
|
|
|
|
|
|
|
|
|
|
|
// 1.根据明细找主表
|
|
|
|
|
|
JSONObject jsonMst = mst.query("order_id = '" + order_id + "' and is_deleted ='0'").uniqueResult(0); |
|
|
|
|
|
|
|
|
|
|
|
// 2.根据明细template_id 找到对应的模板
|
|
|
|
|
|
JSONObject jsonStor = WQL.getWO("QPRODUCESHIFTORDER").addParam("flag", "3").addParam("storage_id", template_id).process().uniqueResult(0); |
|
|
|
|
|
|
|
|
|
|
|
// 3.创建模板工作簿 并指定储存路径
|
|
|
|
|
|
String path = jsonStor.getString("path"); |
|
|
|
|
|
String pathName = "D:\\work\\"+jsonStor.getString("name")+ jsonStor.getString("storage_id") + ".xlsx"; |
|
|
|
|
|
ExcelWriter workBook = EasyExcel.write(pathName).withTemplate(path).build(); |
|
|
|
|
|
// 获取第一个sheet
|
|
|
|
|
|
WriteSheet sheet = EasyExcel.writerSheet().build(); |
|
|
|
|
|
|
|
|
|
|
|
// 4.将主表当中的属性填充到excel当中
|
|
|
|
|
|
HashMap<String, String> map = new HashMap<>(); |
|
|
|
|
|
map.put("material_name",jsonMst.getString("material_code")); |
|
|
|
|
|
map.put("qty",jsonMst.getString("qty")); |
|
|
|
|
|
map.put("tttt",jsonMst.getString("qty")); |
|
|
|
|
|
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(1240,1754); |
|
|
|
|
|
paper.setImageableArea(0, 0, 1240, 1754); |
|
|
|
|
|
pageFormat.setPaper(paper); |
|
|
|
|
|
printerJob.setCopies(1); |
|
|
|
|
|
printerJob.setPrintable(workbook, pageFormat); |
|
|
|
|
|
try { |
|
|
|
|
|
// 执行打印
|
|
|
|
|
|
printerJob.print(); |
|
|
|
|
|
} catch (PrinterException e) { |
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |