package com.stylefeng.guns; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.stylefeng.guns.core.common.exception.BizExceptionEnum; import com.stylefeng.guns.core.exception.GunsException; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.server.model.DeliveryOrder; import com.stylefeng.guns.modular.server.model.DeliveryOrderLine; import com.stylefeng.guns.modular.server.service.*; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.jdbc.BadSqlGrammarException; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import java.util.List; @RunWith(SpringJUnit4ClassRunner.class) @SpringBootTest(classes = GunsApplication.class) public class TestTest { @Autowired IEntryOrderService entryOrderService; @Autowired IDeliveryOrderService deliveryOrderService; @Autowired IDeliveryOrderLineService deliveryOrderLineService; @Test public void test(){ try{ String no = entryOrderService.getNextEntryOrderNo(1003); System.out.println("獲取入庫單號 : " + no); } catch(BadSqlGrammarException e){ System.out.println("exception : " + e); if(e.getCause().toString().contains("raise_application_error")){ String msg = entryOrderService.getError(); BizExceptionEnum.SESSION_LAST_ERROR.setMessage(msg); throw new GunsException(BizExceptionEnum.SESSION_LAST_ERROR); } BizExceptionEnum.SESSION_LAST_ERROR.setMessage(e.getMessage()); throw new GunsException(BizExceptionEnum.SESSION_LAST_ERROR); }catch (Exception e){ BizExceptionEnum.SESSION_LAST_ERROR.setMessage(e.getMessage()); throw new GunsException(BizExceptionEnum.SESSION_LAST_ERROR); } } @Test public void test1(){ // List<DeliveryOrder> deliveryOrderList = deliveryOrderService.selectList( // new EntityWrapper<DeliveryOrder>() // .eq("part_count",0) // .eq("rowstate",1) // ); // for (DeliveryOrder deliveryOrder: deliveryOrderList){ // if (ToolUtil.isEmpty(deliveryOrder.getPartList())){ // List<DeliveryOrderLine> deliveryOrderLineList = deliveryOrderLineService.selectList( // new EntityWrapper<DeliveryOrderLine>() // .eq("order_no",deliveryOrder.getOrderNo()) // .eq("logistics_company_id",deliveryOrder.getLogisticsCompanyId()) // .orderBy("ean_no",true) // ); // String partList = ""; // Integer totalQt = 0; // if (deliveryOrderLineList.size() > 0) { // for (DeliveryOrderLine item : deliveryOrderLineList) { // partList = partList // + item.getEanNo().trim()+ "^" // +item.getQuantity().toString() // + "^" + "10003" // + "^" + deliveryOrder.getWarehouse() // + "^" + deliveryOrder.getOwnerId() // + "^" + deliveryOrder.getExprCompany() // + ","; // totalQt = totalQt + item.getQuantity(); // } // partList = partList.substring(0, partList.length() - 1); // } // deliveryOrder.setGoodsCount(totalQt); // deliveryOrder.setPartCount(deliveryOrderLineList.size()); // deliveryOrder.setPartList(ToolUtil.toStr(ToolUtil.toHash(partList))); // deliveryOrderService.updateById(deliveryOrder); // } // } // HttpServletResponse response = HttpKit.getResponse(); // try { // // 網絡pdf文件全路徑 // String pdfUrl ="http://182.254.230.150:8089/helloworld.pdf"; // URL url = new URL(pdfUrl); // HttpURLConnection conn = (HttpURLConnection)url.openConnection(); // conn.setConnectTimeout(5*1000); // InputStream inputStream = conn.getInputStream(); // response.setHeader("Content-Disposition", "attachment;fileName=helloword.pdf"); // response.setContentType("multipart/form-data"); // OutputStream outputStream = response.getOutputStream(); // IOUtils.write(IOUtils.toByteArray(inputStream), outputStream); // System.out.println(outputStream); // } catch (Exception e) { // e.printStackTrace(); // } } }