|
@@ -7,11 +7,17 @@ import java.net.URLDecoder;
|
|
|
import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.GsonBuilder;
|
|
|
+import org.apache.commons.beanutils.PropertyUtils;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
+import org.jeecg.common.system.base.controller.JeecgController;
|
|
|
import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.apache.shiro.SecurityUtils;
|
|
|
import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetails;
|
|
@@ -19,12 +25,19 @@ import org.jeecg.modules.documents.shippingDetails.entity.SyShippingDetailsItem;
|
|
|
import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
|
|
|
import org.jeecg.modules.documents.shippingDetails.service.ISyShippingDetailsItemService;
|
|
|
import org.jeecg.modules.documents.shippingDetails.service.ISyShippingDetailsService;
|
|
|
+import org.jeecg.modules.openApi.entity.DxpDataPlan;
|
|
|
+import org.jeecg.modules.openApi.service.IDxpDataPlanService;
|
|
|
+import org.jeecg.modules.scas.entity.SyCostAllocationSummary;
|
|
|
+import org.jeecg.modules.scas.service.ISyCostAllocationSummaryService;
|
|
|
import org.jeecg.modules.spapl.entity.SizeTable;
|
|
|
+import org.jeecg.modules.spapl.vo.PackingHeaderVo;
|
|
|
import org.jeecg.modules.spapl.vo.SyPreAssembledPackingListVo;
|
|
|
+import org.jeecg.modules.system.util.InterfaceConnUtils;
|
|
|
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
|
|
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
|
|
import org.jeecgframework.poi.excel.entity.ExportParams;
|
|
|
import org.jeecgframework.poi.excel.entity.ImportParams;
|
|
|
+import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
|
|
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
|
|
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
@@ -60,7 +73,7 @@ import org.jeecg.common.aspect.annotation.AutoLog;
|
|
|
@RestController
|
|
|
@RequestMapping("/spapl/syPreAssembledPackingList")
|
|
|
@Slf4j
|
|
|
-public class SyPreAssembledPackingListController {
|
|
|
+public class SyPreAssembledPackingListController extends JeecgController<SyPreAssembledPackingList, ISyPreAssembledPackingListService>{
|
|
|
@Autowired
|
|
|
private ISyPreAssembledPackingListService syPreAssembledPackingListService;
|
|
|
@Autowired
|
|
@@ -69,7 +82,8 @@ public class SyPreAssembledPackingListController {
|
|
|
private ISyShippingDetailsService syShippingDetailsService;
|
|
|
@Autowired
|
|
|
private ISyShippingDetailsItemService syShippingDetailsItemService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IDxpDataPlanService iDxpDataPlanService;
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
@@ -79,7 +93,8 @@ public class SyPreAssembledPackingListController {
|
|
|
* @param req
|
|
|
* @return
|
|
|
*/
|
|
|
- /*@AutoLog(value = "预装箱单主表-分页列表查询")
|
|
|
+/*
|
|
|
+ @AutoLog(value = "预装箱单主表-分页列表查询")
|
|
|
@ApiOperation(value="预装箱单主表-分页列表查询", notes="预装箱单主表-分页列表查询")
|
|
|
@GetMapping(value = "/list")
|
|
|
public Result<IPage<SyPreAssembledPackingList>> queryPageList(SyPreAssembledPackingList syPreAssembledPackingList,
|
|
@@ -101,7 +116,8 @@ public class SyPreAssembledPackingListController {
|
|
|
Page<SyPreAssembledPackingList> page = new Page<SyPreAssembledPackingList>(pageNo, pageSize);
|
|
|
IPage<SyPreAssembledPackingList> pageList = syPreAssembledPackingListService.page(page, queryWrapper);
|
|
|
return Result.OK(pageList);
|
|
|
- }*/
|
|
|
+ }
|
|
|
+*/
|
|
|
|
|
|
/**
|
|
|
* 分页列表查询
|
|
@@ -119,8 +135,12 @@ public class SyPreAssembledPackingListController {
|
|
|
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
|
|
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
|
|
HttpServletRequest req) {
|
|
|
- QueryWrapper<SyPreAssembledPackingListVo> queryWrapper = QueryGenerator.initQueryWrapper(syPreAssembledPackingListVo, req.getParameterMap());
|
|
|
+ //System.out.println("当前登录用户:"+((LoginUser)SecurityUtils.getSubject().getPrincipal()).getRealname());
|
|
|
+ QueryWrapper<SyPreAssembledPackingListVo> queryWrapper =new QueryWrapper<>();//初始化
|
|
|
queryWrapper.eq("a.del_flag","0");//默认查询未删除
|
|
|
+ if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getId())){//查询id
|
|
|
+ queryWrapper.eq("a.id",syPreAssembledPackingListVo.getId());
|
|
|
+ }
|
|
|
if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getOrderNumber())){
|
|
|
queryWrapper.eq("a.order_number",syPreAssembledPackingListVo.getOrderNumber());//订单号
|
|
|
}
|
|
@@ -175,9 +195,9 @@ public class SyPreAssembledPackingListController {
|
|
|
result.setMessage("未找到id");
|
|
|
}
|
|
|
SyPreAssembledPackingList syPreAssembledPackingList=syPreAssembledPackingListService.queryPageList3(id);//获取数据
|
|
|
- for(SyPreAssembledPackingListItem spapl_item : syPreAssembledPackingList.getSyPreAssembledPackingListItemList()){
|
|
|
+ /*for(SyPreAssembledPackingListItem spapl_item : syPreAssembledPackingList.getSyPreAssembledPackingListItemList()){
|
|
|
spapl_item.setSizeTables(syPreAssembledPackingListItemService.selectSize(spapl_item.getWithCode(),spapl_item.getTotal()));
|
|
|
- }
|
|
|
+ }*/
|
|
|
result.setSuccess(true);
|
|
|
result.setResult(syPreAssembledPackingList);
|
|
|
result.setMessage("查询成功!");
|
|
@@ -201,7 +221,7 @@ public class SyPreAssembledPackingListController {
|
|
|
result.setSuccess(false);
|
|
|
return result;
|
|
|
}
|
|
|
- syPreAssembledPackingList=syPreAssembledPackingListService.saveMain(syPreAssembledPackingList);
|
|
|
+ syPreAssembledPackingList=syPreAssembledPackingListService.saveMain2(syPreAssembledPackingList);
|
|
|
result.setSuccess(true);
|
|
|
result.setMessage("添加成功");
|
|
|
result.setResult(syPreAssembledPackingList);
|
|
@@ -241,7 +261,7 @@ public class SyPreAssembledPackingListController {
|
|
|
result.setSuccess(false);
|
|
|
return result;
|
|
|
}
|
|
|
- syPreAssembledPackingListService.updateMain(syPreAssembledPackingList);
|
|
|
+ syPreAssembledPackingListService.updateMain2(syPreAssembledPackingList);
|
|
|
result.setSuccess(true);
|
|
|
result.setMessage("修改成功");
|
|
|
result.setResult(syPreAssembledPackingList);
|
|
@@ -255,15 +275,73 @@ public class SyPreAssembledPackingListController {
|
|
|
|
|
|
/**
|
|
|
* 推送
|
|
|
- *
|
|
|
- * @param syPreAssembledPackingList
|
|
|
+ * @param id
|
|
|
* @return
|
|
|
*/
|
|
|
- @AutoLog(value = "预装箱单主表-推送(未完成)")
|
|
|
- @ApiOperation(value="预装箱单主表-推送(未完成)", notes="预装箱单主表-推送(未完成)")
|
|
|
+ @AutoLog(value = "预装箱单主表-推送")
|
|
|
+ @ApiOperation(value="预装箱单主表-推送", notes="预装箱单主表-推送")
|
|
|
@RequestMapping(value = "/push", method = {RequestMethod.GET})
|
|
|
- public Result<?> push(@RequestBody SyPreAssembledPackingList syPreAssembledPackingList) {
|
|
|
- return Result.OK("该功能暂未完成!!");
|
|
|
+ public JSONObject push(@RequestParam(value = "id",required = true) String id) {
|
|
|
+
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
+ List<PackingHeaderVo> list=new ArrayList<>();
|
|
|
+ try{
|
|
|
+ if(oConvertUtils.isEmpty(id)){
|
|
|
+ log.warn("id为空值");
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //查询IP及账套信息、时间戳
|
|
|
+ QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
|
|
|
+ //获取推送接口地址
|
|
|
+ queryWrapper.eq("code", "senYu_syShipping").or().eq("code","senYu_SH_token");
|
|
|
+ queryWrapper.orderBy(true,true,"id");
|
|
|
+ Page<DxpDataPlan> page = new Page<DxpDataPlan>(1, 10);
|
|
|
+ IPage<DxpDataPlan> pageList = iDxpDataPlanService.page(page, queryWrapper);
|
|
|
+ List<DxpDataPlan> resultList = pageList.getRecords();
|
|
|
+
|
|
|
+ PackingHeaderVo vo=syPreAssembledPackingListService.pushData(id);
|
|
|
+ list.add(vo);
|
|
|
+ Gson userGson = new GsonBuilder().create();
|
|
|
+ result.put("payload", userGson.toJson(JSONObject.toJSON(list)));
|
|
|
+ log.info("JSON数据:" + result);
|
|
|
+
|
|
|
+ String url = resultList.get(0).getItemIp() + resultList.get(0).getItemUrl();//拼接url
|
|
|
+
|
|
|
+ String tokenUrl = resultList.get(1).getItemIp()+resultList.get(1).getItemUrl();//获取token
|
|
|
+
|
|
|
+ if(oConvertUtils.isEmpty(url)||oConvertUtils.isEmpty(tokenUrl)){
|
|
|
+ log.warn("缺少推送接口信息" );
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ //调用doPost
|
|
|
+ InterfaceConnUtils interfaceConnUtils = new InterfaceConnUtils();
|
|
|
+ //处理返回信息
|
|
|
+ JSONObject informationJson = interfaceConnUtils.doPostToBearer(result, url,tokenUrl, "发预装箱单接口-");
|
|
|
+ //获取返回信息
|
|
|
+ JSONObject jsonArray = informationJson.getJSONObject("payload");
|
|
|
+
|
|
|
+ //获取code判断是否成功
|
|
|
+ String code = jsonArray.getString("code");
|
|
|
+ //获取返回消息
|
|
|
+ String message = jsonArray.getString("message");
|
|
|
+
|
|
|
+ SyPreAssembledPackingList syPreAssembledPackingList = syPreAssembledPackingListService.getById(id);
|
|
|
+ if(code.equals("S")){
|
|
|
+ syPreAssembledPackingList.setPushStatus("1");
|
|
|
+ System.out.println("推送过去了");
|
|
|
+ }else{
|
|
|
+ syPreAssembledPackingList.setPushStatus("2");
|
|
|
+ System.out.println("推送失败了");
|
|
|
+ }
|
|
|
+ syPreAssembledPackingListService.updateById(syPreAssembledPackingList);
|
|
|
+
|
|
|
+ }catch (Exception ex){
|
|
|
+ ex.printStackTrace();
|
|
|
+ log.error("推送失败:" + ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return result;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -410,8 +488,13 @@ public class SyPreAssembledPackingListController {
|
|
|
queryWrapper.eq("id",id).eq("del_flag",0);//预装箱单主表id
|
|
|
SyPreAssembledPackingList preAssembledPackingList=syPreAssembledPackingListService.queryById(queryWrapper);//已筛选删除状态
|
|
|
List<SyPreAssembledPackingListItem> spaplItems = syPreAssembledPackingListItemService.selectByMainId(id);//已筛选删除状态
|
|
|
+ List<String> strings=new ArrayList<>();
|
|
|
if(spaplItems.size()>0){
|
|
|
preAssembledPackingList.setSyPreAssembledPackingListItemList(spaplItems);
|
|
|
+// for (SyPreAssembledPackingListItem item : spaplItems){
|
|
|
+// strings.add(item.getSyDeclarationElementsId());
|
|
|
+// }
|
|
|
+ //preAssembledPackingList.setSizeTables(syPreAssembledPackingListItemService.querySizes(strings.toArray(new String[strings.size()])));
|
|
|
}
|
|
|
result.setMessage("查询成功!");
|
|
|
result.setSuccess(true);
|
|
@@ -425,7 +508,7 @@ public class SyPreAssembledPackingListController {
|
|
|
* @param id
|
|
|
* @return
|
|
|
*/
|
|
|
- @AutoLog(value = "预装箱单子表-通过主表ID查询")
|
|
|
+ /*@AutoLog(value = "预装箱单子表-通过主表ID查询")
|
|
|
@ApiOperation(value="预装箱单子表-通过主表ID查询", notes="预装箱单主表-通过主表ID查询")
|
|
|
@GetMapping(value = "/querySyPreAssembledPackingListItemByMainId")
|
|
|
public Result<?> querySyPreAssembledPackingListItemListByMainId(@RequestParam(name="id",required=true) String id) {
|
|
@@ -441,86 +524,82 @@ public class SyPreAssembledPackingListController {
|
|
|
result.setMessage("查询成功!");
|
|
|
}
|
|
|
return result;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 导出excel
|
|
|
- * 不传数据就是导出全部,传id就根据id查询导出
|
|
|
- * @param request
|
|
|
- * @param syPreAssembledPackingList
|
|
|
- */
|
|
|
- @RequestMapping(value = "/exportXls")
|
|
|
- public ModelAndView exportXls(HttpServletRequest request, SyPreAssembledPackingList syPreAssembledPackingList) {
|
|
|
- // Step.1 组装查询条件
|
|
|
- QueryWrapper<SyPreAssembledPackingList> queryWrapper = QueryGenerator.initQueryWrapper(syPreAssembledPackingList, request.getParameterMap());
|
|
|
- LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
|
|
+ }*/
|
|
|
|
|
|
- //Step.2 获取导出数据
|
|
|
- List<SyPreAssembledPackingListPage> pageList = new ArrayList<SyPreAssembledPackingListPage>();
|
|
|
- List<SyPreAssembledPackingList> syPreAssembledPackingListList = syPreAssembledPackingListService.list(queryWrapper);
|
|
|
- for (SyPreAssembledPackingList temp : syPreAssembledPackingListList) {
|
|
|
- SyPreAssembledPackingListPage vo = new SyPreAssembledPackingListPage();
|
|
|
- BeanUtils.copyProperties(temp, vo);
|
|
|
- List<SyPreAssembledPackingListItem> syPreAssembledPackingListItemList = syPreAssembledPackingListItemService.selectByMainId(temp.getId());
|
|
|
- vo.setSyPreAssembledPackingListItemList(syPreAssembledPackingListItemList);
|
|
|
- pageList.add(vo);
|
|
|
- }
|
|
|
- //Step.3 调用AutoPoi导出Excel
|
|
|
- ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
|
|
- mv.addObject(NormalExcelConstants.FILE_NAME, "预装箱单主表");
|
|
|
- mv.addObject(NormalExcelConstants.CLASS, SyPreAssembledPackingListPage.class);
|
|
|
- mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("预装箱单主表数据", "导出人:admin", "预装箱单主表"));
|
|
|
- mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
|
|
|
- return mv;
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 导出excel
|
|
|
+ * 不传数据就是导出全部,传id就根据id查询导出
|
|
|
+ * @param request
|
|
|
+ * @param syPreAssembledPackingList
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/exportXls")
|
|
|
+ public ModelAndView exportXls(HttpServletRequest request, SyPreAssembledPackingList syPreAssembledPackingList) throws Exception {
|
|
|
+ // Step.1 组装查询条件
|
|
|
+ QueryWrapper<SyPreAssembledPackingList> queryWrapper = QueryGenerator.initQueryWrapper(syPreAssembledPackingList, request.getParameterMap());
|
|
|
+ queryWrapper.eq("del_flag","0");
|
|
|
+ //Step.2 获取导出数据
|
|
|
+ List<SyPreAssembledPackingList> syPreAssembledPackingListList = syPreAssembledPackingListService.list(queryWrapper);
|
|
|
+ for (SyPreAssembledPackingList temp : syPreAssembledPackingListList) {
|
|
|
+ List<SyPreAssembledPackingListItem> syPreAssembledPackingListItemList = syPreAssembledPackingListItemService.selectByMainId(temp.getId());
|
|
|
+ temp.setSyPreAssembledPackingListItemList(syPreAssembledPackingListItemList);
|
|
|
+ }
|
|
|
+ return exportXlsSheet2(request,SyPreAssembledPackingList.class,syPreAssembledPackingListList,"预装箱单",1);
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 通过excel导入数据
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return
|
|
|
- */
|
|
|
- @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
- public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
- MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
- Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
- for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
- MultipartFile file = entity.getValue();// 获取上传文件对象
|
|
|
- ImportParams params = new ImportParams();
|
|
|
- params.setTitleRows(2);
|
|
|
- params.setHeadRows(1);
|
|
|
- params.setNeedSave(true);
|
|
|
- try {
|
|
|
- List<SyPreAssembledPackingListPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SyPreAssembledPackingListPage.class, params);
|
|
|
- for (SyPreAssembledPackingListPage page : list) {
|
|
|
- SyPreAssembledPackingList po = new SyPreAssembledPackingList();
|
|
|
- BeanUtils.copyProperties(page, po);
|
|
|
- po.setSyPreAssembledPackingListItemList(page.getSyPreAssembledPackingListItemList());
|
|
|
- syPreAssembledPackingListService.saveMain(po);
|
|
|
- }
|
|
|
- return Result.OK("文件导入成功!数据行数:" + list.size());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error(e.getMessage(),e);
|
|
|
- return Result.error("文件导入失败:"+e.getMessage());
|
|
|
- } finally {
|
|
|
- try {
|
|
|
- file.getInputStream().close();
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return Result.OK("文件导入失败!");
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 通过excel导入数据
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
|
|
+ public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
|
|
+ Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
|
|
+ for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
|
|
+ MultipartFile file = entity.getValue();// 获取上传文件对象
|
|
|
+ ImportParams params = new ImportParams();
|
|
|
+ params.setTitleRows(2);
|
|
|
+ params.setHeadRows(1);
|
|
|
+ params.setNeedSave(true);
|
|
|
+ try {
|
|
|
+ List<SyPreAssembledPackingListPage> list = ExcelImportUtil.importExcel(file.getInputStream(), SyPreAssembledPackingListPage.class, params);
|
|
|
+ for (SyPreAssembledPackingListPage page : list) {
|
|
|
+ SyPreAssembledPackingList po = new SyPreAssembledPackingList();
|
|
|
+ BeanUtils.copyProperties(page, po);
|
|
|
+ po.setSyPreAssembledPackingListItemList(page.getSyPreAssembledPackingListItemList());
|
|
|
+ syPreAssembledPackingListService.saveMain(po);
|
|
|
+ }
|
|
|
+ return Result.OK("文件导入成功!数据行数:" + list.size());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error(e.getMessage(),e);
|
|
|
+ return Result.error("文件导入失败:"+e.getMessage());
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ file.getInputStream().close();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.OK("文件导入失败!");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
- @AutoLog(value = "二维表格测试")
|
|
|
+ /* @AutoLog(value = "二维表格测试")
|
|
|
@ApiOperation(value="二维表格测试", notes="二维表格测试")
|
|
|
@GetMapping(value = "/selecSize")
|
|
|
- public List<SizeTable> table(@RequestParam(name="str",required=true)String str,
|
|
|
- @RequestParam(name="orderNum",required=true) BigDecimal orderNum){
|
|
|
- return syPreAssembledPackingListItemService.selectSize(str,orderNum);
|
|
|
- }
|
|
|
+ public List<SizeTable> table(@RequestParam(name="str",required=true)String str,
|
|
|
+ @RequestParam(name="orderNum",required=true) BigDecimal orderNum){
|
|
|
+ return syPreAssembledPackingListItemService.selectSize(str,orderNum);
|
|
|
+ }*/
|
|
|
+
|
|
|
+ /* @AutoLog(value = "尺码")
|
|
|
+ @ApiOperation(value="尺码", notes="尺码")
|
|
|
+ @GetMapping(value = "/querySizes")
|
|
|
+ public List<SizeTable> table(@RequestParam(name="ids",required=true)String ids){
|
|
|
+ return syPreAssembledPackingListItemService.querySizes(ids.split(","));
|
|
|
+ }*/
|
|
|
}
|