大家好,又见面了,我是你们的朋友全栈君。
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();
// }
}
}
转载于:https://my.oschina.net/u/3556610/blog/3022405
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/106931.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...