|  | @@ -1,6 +1,7 @@
 | 
	
		
			
				|  |  |  package org.jeecg.modules.spapl.controller;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import java.io.IOException;
 | 
	
		
			
				|  |  | +import java.lang.reflect.Array;
 | 
	
		
			
				|  |  |  import java.text.SimpleDateFormat;
 | 
	
		
			
				|  |  |  import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -8,9 +9,13 @@ import javax.servlet.http.HttpServletRequest;
 | 
	
		
			
				|  |  |  import javax.servlet.http.HttpServletResponse;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 | 
	
		
			
				|  |  |  import com.google.gson.Gson;
 | 
	
		
			
				|  |  |  import com.google.gson.GsonBuilder;
 | 
	
		
			
				|  |  | +import org.jeecg.common.constant.CommonConstant;
 | 
	
		
			
				|  |  |  import org.jeecg.common.system.base.controller.JeecgController;
 | 
	
		
			
				|  |  | +import org.jeecg.common.system.util.JwtUtil;
 | 
	
		
			
				|  |  | +import org.jeecg.common.util.RedisUtil;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.openApi.entity.DxpDataPlan;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.openApi.service.IDxpDataPlanService;
 | 
	
	
		
			
				|  | @@ -30,6 +35,7 @@ import org.jeecg.modules.spapl.service.ISyPreAssembledPackingListService;
 | 
	
		
			
				|  |  |  import org.jeecg.modules.spapl.service.ISyPreAssembledPackingListItemService;
 | 
	
		
			
				|  |  |  import org.springframework.beans.BeanUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  | +import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  import org.springframework.web.bind.annotation.*;
 | 
	
		
			
				|  |  |  import org.springframework.web.servlet.ModelAndView;
 | 
	
		
			
				|  |  |  import org.springframework.web.multipart.MultipartFile;
 | 
	
	
		
			
				|  | @@ -59,6 +65,8 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 | 
	
		
			
				|  |  |  	private ISyPreAssembledPackingListItemService syPreAssembledPackingListItemService;
 | 
	
		
			
				|  |  |  	@Autowired
 | 
	
		
			
				|  |  |  	private IDxpDataPlanService iDxpDataPlanService;
 | 
	
		
			
				|  |  | +	@Autowired
 | 
	
		
			
				|  |  | +	private RedisUtil redisUtil;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	/**
 | 
	
		
			
				|  |  |  	 * 分页列表查询
 | 
	
	
		
			
				|  | @@ -110,6 +118,8 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 | 
	
		
			
				|  |  |  	 public Result<IPage<SyPreAssembledPackingListVo>> queryPageList2(SyPreAssembledPackingListVo syPreAssembledPackingListVo,
 | 
	
		
			
				|  |  |  									 @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 | 
	
		
			
				|  |  |  									 @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
 | 
	
		
			
				|  |  | +									 String stratDate,
 | 
	
		
			
				|  |  | +									 String endDate,
 | 
	
		
			
				|  |  |  									 HttpServletRequest req) {
 | 
	
		
			
				|  |  |  		 //System.out.println("当前登录用户:"+((LoginUser)SecurityUtils.getSubject().getPrincipal()).getRealname());
 | 
	
		
			
				|  |  |  		 QueryWrapper<SyPreAssembledPackingListVo> queryWrapper =new QueryWrapper<>();//初始化
 | 
	
	
		
			
				|  | @@ -117,14 +127,28 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 | 
	
		
			
				|  |  |  		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getId())){//查询id
 | 
	
		
			
				|  |  |  		 	queryWrapper.eq("a.id",syPreAssembledPackingListVo.getId());
 | 
	
		
			
				|  |  |  		 }
 | 
	
		
			
				|  |  | -		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getOrderNumber())){
 | 
	
		
			
				|  |  | -			 queryWrapper.eq("a.order_number",syPreAssembledPackingListVo.getOrderNumber());//订单号
 | 
	
		
			
				|  |  | +		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getOrderNumber())){//订单号
 | 
	
		
			
				|  |  | +			 queryWrapper.eq("a.order_number",syPreAssembledPackingListVo.getOrderNumber());
 | 
	
		
			
				|  |  | +		 }
 | 
	
		
			
				|  |  | +		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getItemNumber())){//款号
 | 
	
		
			
				|  |  | +			 queryWrapper.eq("a.item_number",syPreAssembledPackingListVo.getItemNumber());
 | 
	
		
			
				|  |  | +		 }
 | 
	
		
			
				|  |  | +		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getProductName())){//品名
 | 
	
		
			
				|  |  | +			 queryWrapper.eq("a.product_Name",syPreAssembledPackingListVo.getProductName());
 | 
	
		
			
				|  |  | +		 }
 | 
	
		
			
				|  |  | +		 // 小po 分销点
 | 
	
		
			
				|  |  | +		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getSmallPo())){//小po
 | 
	
		
			
				|  |  | +			 queryWrapper.eq("b.small_Po",syPreAssembledPackingListVo.getSmallPo());
 | 
	
		
			
				|  |  |  		 }
 | 
	
		
			
				|  |  | -		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getItemNumber())){
 | 
	
		
			
				|  |  | -			 queryWrapper.eq("a.item_number",syPreAssembledPackingListVo.getItemNumber());//款号
 | 
	
		
			
				|  |  | +		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getDistributionPoint())){//分销点
 | 
	
		
			
				|  |  | +			 queryWrapper.eq("b.distribution_Point",syPreAssembledPackingListVo.getDistributionPoint());
 | 
	
		
			
				|  |  |  		 }
 | 
	
		
			
				|  |  | -		 if(oConvertUtils.isNotEmpty(syPreAssembledPackingListVo.getProductName())){
 | 
	
		
			
				|  |  | -			 queryWrapper.eq("a.product_Name",syPreAssembledPackingListVo.getProductName());//品名
 | 
	
		
			
				|  |  | +		 //预发货日期
 | 
	
		
			
				|  |  | +		 if(oConvertUtils.isNotEmpty(stratDate)){//起始
 | 
	
		
			
				|  |  | +			 queryWrapper.ge("b.hod",stratDate);
 | 
	
		
			
				|  |  | +		 }
 | 
	
		
			
				|  |  | +		 if(oConvertUtils.isNotEmpty(endDate)){//结束
 | 
	
		
			
				|  |  | +			 queryWrapper.le("b.hod",endDate);
 | 
	
		
			
				|  |  |  		 }
 | 
	
		
			
				|  |  |  		 Page<SyPreAssembledPackingListVo> page = new Page<SyPreAssembledPackingListVo>(pageNo, pageSize);
 | 
	
		
			
				|  |  |  		 IPage<SyPreAssembledPackingListVo> pageList = syPreAssembledPackingListService.selectPage(page, queryWrapper);
 | 
	
	
		
			
				|  | @@ -334,6 +358,94 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  	 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 推送测试
 | 
	
		
			
				|  |  | +	 * @param ids
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@AutoLog(value = "批量推送")
 | 
	
		
			
				|  |  | +	@ApiOperation(value="批量推送", notes="批量推送")
 | 
	
		
			
				|  |  | +	@RequestMapping(value = "/pushBatch", method = {RequestMethod.GET})
 | 
	
		
			
				|  |  | +	public JSONObject pushBatch(@RequestParam(value = "id",required = true) String[] ids) {
 | 
	
		
			
				|  |  | +		JSONObject result=new JSONObject();
 | 
	
		
			
				|  |  | +		List<PackingHeaderVo> list=new ArrayList<>();
 | 
	
		
			
				|  |  | +		try{
 | 
	
		
			
				|  |  | +			if(oConvertUtils.isEmpty(ids)){
 | 
	
		
			
				|  |  | +				log.warn("id为空");
 | 
	
		
			
				|  |  | +				return null;
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			//查询IP及账套信息、时间戳
 | 
	
		
			
				|  |  | +			QueryWrapper<DxpDataPlan> queryWrapper = new QueryWrapper<>();
 | 
	
		
			
				|  |  | +			//获取推送接口地址
 | 
	
		
			
				|  |  | +			queryWrapper.eq("code", "senYu_YCY_local").or().eq("code","senYu_YCY_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();
 | 
	
		
			
				|  |  | +			list = syPreAssembledPackingListService.pushDataBatch(ids);
 | 
	
		
			
				|  |  | +			System.out.println("list的长度:\t"+list.size());
 | 
	
		
			
				|  |  | +			list.forEach(System.out::println);
 | 
	
		
			
				|  |  | +			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");
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +			UpdateWrapper<SyPreAssembledPackingList> wrapper=new UpdateWrapper<>();
 | 
	
		
			
				|  |  | +			if(code.equals("S")){
 | 
	
		
			
				|  |  | +				wrapper.set("push_Status","1");//推送过去
 | 
	
		
			
				|  |  | +				wrapper.in(" id",ids);
 | 
	
		
			
				|  |  | +				System.out.println("推送过去了");
 | 
	
		
			
				|  |  | +			}else{
 | 
	
		
			
				|  |  | +				wrapper.set("push_Status","2");//推送失败
 | 
	
		
			
				|  |  | +				wrapper.in(" id",ids);
 | 
	
		
			
				|  |  | +				System.out.println("推送失败了");
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			syPreAssembledPackingListService.update(wrapper);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		}catch (Exception ex){
 | 
	
		
			
				|  |  | +			ex.printStackTrace();
 | 
	
		
			
				|  |  | +			log.error("推送失败:" + ex.getMessage());
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +		return result;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * testtest
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @param username,syspassword
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@AutoLog(value = "获取token")
 | 
	
		
			
				|  |  | +	@ApiOperation(value="获取token", notes="获取token")
 | 
	
		
			
				|  |  | +	@RequestMapping(value = "/getToken", method = {RequestMethod.GET})
 | 
	
		
			
				|  |  | +	public String getToken(String username,String syspassword) {
 | 
	
		
			
				|  |  | +		String token = JwtUtil.sign(username, syspassword);
 | 
	
		
			
				|  |  | +		redisUtil.set(CommonConstant.PREFIX_USER_TOKEN + token, token);
 | 
	
		
			
				|  |  | +		redisUtil.expire(CommonConstant.PREFIX_USER_TOKEN + token, JwtUtil.EXPIRE_TIME * 2 / 1000);
 | 
	
		
			
				|  |  | +		System.out.println("CommonConstant.PREFIX_USER_TOKEN"+CommonConstant.PREFIX_USER_TOKEN);
 | 
	
		
			
				|  |  | +		System.out.println("JwtUtil.EXPIRE_TIME"+JwtUtil.EXPIRE_TIME);
 | 
	
		
			
				|  |  | +		return token;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  |  	 /**
 | 
	
		
			
				|  |  |  	  * 提交
 | 
	
		
			
				|  |  |  	  *
 | 
	
	
		
			
				|  | @@ -372,6 +484,39 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 | 
	
		
			
				|  |  |  	 	return result;
 | 
	
		
			
				|  |  |  	 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +	/**
 | 
	
		
			
				|  |  | +	 * 批量提交
 | 
	
		
			
				|  |  | +	 *
 | 
	
		
			
				|  |  | +	 * @param ids
 | 
	
		
			
				|  |  | +	 * @return
 | 
	
		
			
				|  |  | +	 */
 | 
	
		
			
				|  |  | +	@AutoLog(value = "批量提交")
 | 
	
		
			
				|  |  | +	@ApiOperation(value="批量提交", notes="批量提交")
 | 
	
		
			
				|  |  | +	@RequestMapping(value = "/submitBatch", method = {RequestMethod.GET})
 | 
	
		
			
				|  |  | +	public Result<?> submitBatch(@RequestParam(value = "id",required = true) String []ids) {
 | 
	
		
			
				|  |  | +		Result<?> result=new Result<>();
 | 
	
		
			
				|  |  | +		try{
 | 
	
		
			
				|  |  | +			if(oConvertUtils.isEmpty(ids)){
 | 
	
		
			
				|  |  | +				result.setMessage("未获取到任何id!");
 | 
	
		
			
				|  |  | +				result.setSuccess(false);
 | 
	
		
			
				|  |  | +				return result;
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			String message=syPreAssembledPackingListService.submitBatch(ids);
 | 
	
		
			
				|  |  | +			if(!message.equals("提交成功")){
 | 
	
		
			
				|  |  | +				result.setSuccess(false);
 | 
	
		
			
				|  |  | +				result.setMessage(message);
 | 
	
		
			
				|  |  | +				return result;
 | 
	
		
			
				|  |  | +			}
 | 
	
		
			
				|  |  | +			result.setMessage("提交成功!");
 | 
	
		
			
				|  |  | +			result.setSuccess(true);
 | 
	
		
			
				|  |  | +		}catch (Exception ex){
 | 
	
		
			
				|  |  | +			ex.printStackTrace();
 | 
	
		
			
				|  |  | +			log.error("提交失败:" + ex.getMessage());
 | 
	
		
			
				|  |  | +			result.error500("提交失败:" + ex.getMessage());
 | 
	
		
			
				|  |  | +		}
 | 
	
		
			
				|  |  | +		return result;
 | 
	
		
			
				|  |  | +	}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  	 /**
 | 
	
		
			
				|  |  |  	  * 取消提交
 | 
	
		
			
				|  |  |  	  *
 | 
	
	
		
			
				|  | @@ -395,7 +540,7 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 | 
	
		
			
				|  |  |  				 result.setSuccess(false);
 | 
	
		
			
				|  |  |  				 return result;
 | 
	
		
			
				|  |  |  			 }
 | 
	
		
			
				|  |  | -			 if(syPreAssembledPackingList2.getPushStatus().equals("1")){
 | 
	
		
			
				|  |  | +			 if(syPreAssembledPackingList2.getPushStatus().equals("1")||syPreAssembledPackingList2.getIsReference()>0){
 | 
	
		
			
				|  |  |  				 result.setMessage("已推送云工厂或已被下游参照!");
 | 
	
		
			
				|  |  |  				 result.setSuccess(false);
 | 
	
		
			
				|  |  |  				 return result;
 | 
	
	
		
			
				|  | @@ -648,10 +793,4 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 | 
	
		
			
				|  |  |  		return dateNo;
 | 
	
		
			
				|  |  |  	 }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -	@AutoLog(value = "getToken")
 | 
	
		
			
				|  |  | -	@ApiOperation(value="getToken", notes="getToken")
 | 
	
		
			
				|  |  | -	@GetMapping(value = "/token")
 | 
	
		
			
				|  |  | -	public String token(){
 | 
	
		
			
				|  |  | -		return "token";
 | 
	
		
			
				|  |  | -	}
 | 
	
		
			
				|  |  |  }
 |