|
|
@@ -116,6 +116,8 @@ public class SyPackingListTailoringController implements Job {
|
|
|
@Value("${srm.access-token}")
|
|
|
private String srmAccessToken;
|
|
|
|
|
|
+ //推送状态
|
|
|
+ private boolean isRun = false;
|
|
|
/**
|
|
|
* 分页列表查询
|
|
|
*
|
|
|
@@ -542,25 +544,29 @@ public class SyPackingListTailoringController implements Job {
|
|
|
@AutoLog(value = "装箱单成衣-通过id删除")
|
|
|
@ApiOperation(value="装箱单成衣-通过id删除", notes="装箱单成衣-通过id删除")
|
|
|
@DeleteMapping(value = "/delete")
|
|
|
- public Result<?> delete(@RequestParam(name="id",required=true) String id) {
|
|
|
+ public Result<?> delete(@RequestParam(name="id",required=true) String id,HttpServletRequest request) {
|
|
|
if(oConvertUtils.isEmpty(id)){
|
|
|
return Result.ok("id为空!");
|
|
|
}
|
|
|
- syPackingListTailoringService.delMain(id);
|
|
|
+ String accessToken = request.getHeader("X-Access-Token");
|
|
|
+ String username= JwtUtil.getUsername(accessToken);
|
|
|
+ syPackingListTailoringService.delMain(id,username);
|
|
|
return Result.OK("删除成功!");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量删除
|
|
|
*
|
|
|
- * @param ids
|
|
|
+ * @param ids,request
|
|
|
* @return
|
|
|
*/
|
|
|
@AutoLog(value = "装箱单成衣-批量删除")
|
|
|
@ApiOperation(value="装箱单成衣-批量删除", notes="装箱单成衣-批量删除")
|
|
|
@DeleteMapping(value = "/deleteBatch")
|
|
|
- public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String[] ids) {
|
|
|
- this.syPackingListTailoringService.delBatchMain(Arrays.asList(ids));
|
|
|
+ public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String[] ids,HttpServletRequest request) {
|
|
|
+ String accessToken = request.getHeader("X-Access-Token");
|
|
|
+ String username= JwtUtil.getUsername(accessToken);
|
|
|
+ this.syPackingListTailoringService.delBatchMain(Arrays.asList(ids),username);
|
|
|
return Result.OK("批量删除成功!");
|
|
|
}
|
|
|
|
|
|
@@ -1334,10 +1340,10 @@ public class SyPackingListTailoringController implements Job {
|
|
|
@AutoLog(value = "设置redis字符")
|
|
|
@ApiOperation(value="设置redis字符", notes="设置redis字符")
|
|
|
@RequestMapping(value = "/setRedis", method = {RequestMethod.GET})
|
|
|
- public Result setToken(String key,String value) {
|
|
|
+ public Result setToken(String key,boolean value) {
|
|
|
Result result=new Result();
|
|
|
redisUtil.set(key, value);//采购委外入库单
|
|
|
- result.setMessage(value);
|
|
|
+ result.setResult(value);
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@@ -1422,167 +1428,159 @@ public class SyPackingListTailoringController implements Job {
|
|
|
|
|
|
@Override
|
|
|
public void execute(JobExecutionContext context) throws JobExecutionException {
|
|
|
- QueryWrapper <SyPackingListTailoring> queryWrapper=new QueryWrapper();
|
|
|
- queryWrapper.eq("del_flag","0");
|
|
|
- queryWrapper.nested(i->i.ne("recording_Status","1").nested(s->s.eq("push_State","3").or()
|
|
|
- .like("recording_Error","超时").or().eq("recording_Error","null")
|
|
|
- .or().eq("recording_Error","nullnull")
|
|
|
- .or().like("recording_Error","For input string:")
|
|
|
- .or().eq("recording_Error","nullnullnull").or().like("recording_Error","未能捕获到的错误").or().like("recording_Error","重复"))) ;//推送中
|
|
|
- /*queryWrapper.eq("push_State","3");//推送中
|
|
|
- queryWrapper.or();
|
|
|
- queryWrapper.like("recording_Error","超时");//超时*/
|
|
|
- List<SyPackingListTailoring> syPackingListTailorings=syPackingListTailoringService.list(queryWrapper);//修改调整
|
|
|
-
|
|
|
- List<String> ids=new ArrayList<>();
|
|
|
- for (SyPackingListTailoring syPackingListTailoring : syPackingListTailorings){
|
|
|
- ids.add(syPackingListTailoring.getId());
|
|
|
+ if (isRun){
|
|
|
+ return;
|
|
|
}
|
|
|
- if(syPackingListTailorings.size()<=0){
|
|
|
- return;
|
|
|
- }
|
|
|
- // RedisUtil redisUtil
|
|
|
- UpdateWrapper updateWrapper=new UpdateWrapper();
|
|
|
- updateWrapper.set("recording_Status",1);//推送中
|
|
|
- updateWrapper.set("push_State",3);//推送中
|
|
|
- updateWrapper.in("id",ids);
|
|
|
- syPackingListTailoringService.update(updateWrapper);
|
|
|
-
|
|
|
- for (int i=0; i<syPackingListTailorings.size();i++){
|
|
|
- try {
|
|
|
- String message2="";
|
|
|
- String id=syPackingListTailorings.get(i).getId();
|
|
|
- SyPackingListTailoring main=syPackingListTailoringService.getById(id);
|
|
|
- if(main.getIsReference()==0){
|
|
|
- message2="请先做托书再推送";
|
|
|
- }
|
|
|
- Map<String,Object> map=new HashMap<>();
|
|
|
- Map<String,Object> mapdate=syPackingListTailoringService.getSyShippingOrder(id);
|
|
|
- //System.out.println("madate\t"+mapdate);
|
|
|
- if(mapdate!=null){
|
|
|
- if(!mapdate.containsKey("e4")||mapdate.get("e4").equals("0")){
|
|
|
- message2="请先提交托书再推送";
|
|
|
- }
|
|
|
- if(mapdate.containsKey("e1")&&mapdate.get("e1")!=null){
|
|
|
- main.setTheFinalShippingDate(mapdate.get("e1").toString());
|
|
|
- }else{
|
|
|
- message2="请先维护最终船期再推送";
|
|
|
- }
|
|
|
- if(mapdate.containsKey("e2")&&mapdate.get("e2")!=null){
|
|
|
- main.setTheFinalShippingDate2(mapdate.get("e2").toString());
|
|
|
- }
|
|
|
- if(mapdate.containsKey("e3")&&mapdate.get("e3")!=null){
|
|
|
- main.setLatestDateOfShipment2(mapdate.get("e3").toString());
|
|
|
- }else{
|
|
|
- message2="请先维护装运期限再推送";
|
|
|
- }
|
|
|
- }else{
|
|
|
- message2="请先做托书再推送";
|
|
|
- }
|
|
|
- List<SyPackingListTailoringItem> syPackingListTailoringItems=syPackingListTailoringService.getList(main.getId());
|
|
|
- main.setSyPackingListTailoringItemList(syPackingListTailoringItems);
|
|
|
- String message="";//获取报错消息
|
|
|
- if(syPackingListTailoringItems!=null){
|
|
|
- map.put("account",main.getSyPackingListTailoringItemList().get(0).getOmpoAccount());//委外采购账套号
|
|
|
- map.put("account1",main.getSyPackingListTailoringItemList().get(0).getOmpoAccount());//委外采购账套号
|
|
|
- map.put("ompoId",main.getSyPackingListTailoringItemList().get(0).getOmpoId());//采购委外主表id
|
|
|
- SyOrderData syOrderData=syOrderDataMapper.selectById(syPackingListTailoringItems.get(0).getSyOrderDataId());//最终客户
|
|
|
- if(syOrderData!=null){
|
|
|
- main.setEndCustomer(syOrderData.getEndCustomer());
|
|
|
- }
|
|
|
- /*if(syOrderData.getFlag()==1){
|
|
|
- message2="手工匹配订单不能推送";
|
|
|
- }*/
|
|
|
- if(message2.length()>1){
|
|
|
- main.setRecordingError(message2);//报错原因
|
|
|
- main.setRecordingStatus(0);//改成未推送
|
|
|
- main.setPushState("2");//推送失败
|
|
|
- syPackingListTailoringService.updateById(main);
|
|
|
- continue;//本次不循环
|
|
|
- }
|
|
|
- /*if(main.getRecordingStatus()!=null&&main.getRecordingStatus()==1){
|
|
|
- //message2="数据在推送中,请不要重复点击";
|
|
|
- }else{
|
|
|
- main.setRecordingStatus(1);
|
|
|
- syPackingListTailoringService.updateById(main);//修改成衣
|
|
|
- }*/
|
|
|
- SyOrderDataItem syOrderDataItem=syOrderDataItemMapper.selectById(syPackingListTailoringItems.get(0).getSyOrderDataItemId());//供应商全称
|
|
|
- if(syOrderDataItem!=null){
|
|
|
- main.setSupplierCode(syOrderDataItem.getSupplierCode());
|
|
|
+ isRun = true;
|
|
|
+ try {
|
|
|
+ QueryWrapper <SyPackingListTailoring> queryWrapper=new QueryWrapper();
|
|
|
+ queryWrapper.eq("del_flag","0");
|
|
|
+ queryWrapper.nested(i->i.ne("recording_Status","1").nested(s->s.eq("push_State","3").or()
|
|
|
+ .like("recording_Error","超时").or().eq("recording_Error","null")
|
|
|
+ .or().eq("recording_Error","nullnull")
|
|
|
+ .or().like("recording_Error","For input string:")
|
|
|
+ .or().eq("recording_Error","nullnullnull").or().like("recording_Error","未能捕获到的错误").or().like("recording_Error","重复"))) ;//推送中
|
|
|
+ List<SyPackingListTailoring> syPackingListTailorings=syPackingListTailoringService.list(queryWrapper);//修改调整
|
|
|
+ List<String> ids=new ArrayList<>();
|
|
|
+ for (SyPackingListTailoring syPackingListTailoring : syPackingListTailorings){
|
|
|
+ ids.add(syPackingListTailoring.getId());
|
|
|
+ }
|
|
|
+ if(syPackingListTailorings.size()<=0){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // RedisUtil redisUtil
|
|
|
+ UpdateWrapper updateWrapper=new UpdateWrapper();
|
|
|
+ updateWrapper.set("recording_Status",1);//推送中
|
|
|
+ updateWrapper.set("push_State",3);//推送中
|
|
|
+ updateWrapper.in("id",ids);
|
|
|
+ syPackingListTailoringService.update(updateWrapper);
|
|
|
+
|
|
|
+ for (int i=0; i<syPackingListTailorings.size();i++){
|
|
|
+ try {
|
|
|
+ String message2="";
|
|
|
+ String id=syPackingListTailorings.get(i).getId();
|
|
|
+ SyPackingListTailoring main=syPackingListTailoringService.getById(id);
|
|
|
+ if(main.getIsReference()==0){
|
|
|
+ message2="请先做托书再推送";
|
|
|
}
|
|
|
- if(main.getPurchase()==null){
|
|
|
- map.put("mpOrder",main.getSyPackingListTailoringItemList().get(0).getSpurOrSubOrder());//采购委外订单号
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
+ Map<String,Object> mapdate=syPackingListTailoringService.getSyShippingOrder(id);
|
|
|
+ if(mapdate!=null){
|
|
|
+ if(!mapdate.containsKey("e4")||mapdate.get("e4").equals("0")){
|
|
|
+ message2="请先提交托书再推送";
|
|
|
+ }
|
|
|
+ if(mapdate.containsKey("e1")&&mapdate.get("e1")!=null){
|
|
|
+ main.setTheFinalShippingDate(mapdate.get("e1").toString());
|
|
|
+ }else{
|
|
|
+ message2="请先维护最终船期再推送";
|
|
|
+ }
|
|
|
+ if(mapdate.containsKey("e2")&&mapdate.get("e2")!=null){
|
|
|
+ main.setTheFinalShippingDate2(mapdate.get("e2").toString());
|
|
|
+ }
|
|
|
+ if(mapdate.containsKey("e3")&&mapdate.get("e3")!=null){
|
|
|
+ main.setLatestDateOfShipment2(mapdate.get("e3").toString());
|
|
|
+ }else{
|
|
|
+ message2="请先维护装运期限再推送";
|
|
|
+ }
|
|
|
}else{
|
|
|
- map.put("mpOrder",main.getPurchase());//采购委外订单号
|
|
|
+ message2="请先做托书再推送";
|
|
|
}
|
|
|
- /*String venCode=syPackingListTailoringService.getDictValue(main.getGarmentFactory());//根据成衣工厂获取仓库编码
|
|
|
- if(venCode!=null){
|
|
|
- map.put("vencode",venCode);//委外采购账套号
|
|
|
- }*/
|
|
|
- List<DictModel> dictModels=sysDictService.queryDictItemsByCode("Related_units");
|
|
|
- Map<String,List<String>> maps=new HashMap();
|
|
|
- for (DictModel model : dictModels){
|
|
|
- String account= model.getValue().split("-")[0];
|
|
|
- String ccuscode= model.getValue().split("-")[1];
|
|
|
- if (maps.containsKey(account)){
|
|
|
- List<String> customers=maps.get(account);
|
|
|
- customers.add(ccuscode);
|
|
|
+ List<SyPackingListTailoringItem> syPackingListTailoringItems=syPackingListTailoringService.getList(main.getId());
|
|
|
+ main.setSyPackingListTailoringItemList(syPackingListTailoringItems);
|
|
|
+ String message="";//获取报错消息
|
|
|
+ if(syPackingListTailoringItems!=null){
|
|
|
+ map.put("account",main.getSyPackingListTailoringItemList().get(0).getOmpoAccount());//委外采购账套号
|
|
|
+ map.put("account1",main.getSyPackingListTailoringItemList().get(0).getOmpoAccount());//委外采购账套号
|
|
|
+ map.put("ompoId",main.getSyPackingListTailoringItemList().get(0).getOmpoId());//采购委外主表id
|
|
|
+ SyOrderData syOrderData=syOrderDataMapper.selectById(syPackingListTailoringItems.get(0).getSyOrderDataId());//最终客户
|
|
|
+ if(syOrderData!=null){
|
|
|
+ main.setEndCustomer(syOrderData.getEndCustomer());
|
|
|
+ }
|
|
|
+ if(message2.length()>1){
|
|
|
+ main.setRecordingError(message2);//报错原因
|
|
|
+ main.setRecordingStatus(0);//改成未推送
|
|
|
+ main.setPushState("2");//推送失败
|
|
|
+ syPackingListTailoringService.updateById(main);
|
|
|
+ continue;//本次不循环
|
|
|
+ }
|
|
|
+ SyOrderDataItem syOrderDataItem=syOrderDataItemMapper.selectById(syPackingListTailoringItems.get(0).getSyOrderDataItemId());//供应商全称
|
|
|
+ if(syOrderDataItem!=null){
|
|
|
+ main.setSupplierCode(syOrderDataItem.getSupplierCode());
|
|
|
+ }
|
|
|
+ if(main.getPurchase()==null){
|
|
|
+ map.put("mpOrder",main.getSyPackingListTailoringItemList().get(0).getSpurOrSubOrder());//采购委外订单号
|
|
|
}else{
|
|
|
- List<String> customers=new ArrayList<>();
|
|
|
- customers.add(ccuscode);
|
|
|
- maps.put(account,customers);
|
|
|
+ map.put("mpOrder",main.getPurchase());//采购委外订单号
|
|
|
}
|
|
|
- }
|
|
|
- map.put("maps",maps);
|
|
|
- map.put("customerCode","one");//客户编码
|
|
|
- map.put("CVENCODE","one");//供应商编码
|
|
|
- map.put("orderNumber","one");//销售订单号2
|
|
|
- for (int x=0;x<3;x++){//最多循环3次
|
|
|
- try {
|
|
|
- if (map.get("account").equals("103")){
|
|
|
- message+=syPackingListTailoringService.three(main,map);
|
|
|
- }else if(map.get("account").equals("102")){
|
|
|
- message+=syPackingListTailoringService.two(main,map);
|
|
|
- }else if(map.get("account").equals("101")){
|
|
|
- message+=syPackingListTailoringService.one(main,map);
|
|
|
+ List<DictModel> dictModels=sysDictService.queryDictItemsByCode("Related_units");
|
|
|
+ Map<String,List<String>> maps=new HashMap();
|
|
|
+ for (DictModel model : dictModels){
|
|
|
+ String account= model.getValue().split("-")[0];
|
|
|
+ String ccuscode= model.getValue().split("-")[1];
|
|
|
+ if (maps.containsKey(account)){
|
|
|
+ List<String> customers=maps.get(account);
|
|
|
+ customers.add(ccuscode);
|
|
|
}else{
|
|
|
- break;
|
|
|
+ List<String> customers=new ArrayList<>();
|
|
|
+ customers.add(ccuscode);
|
|
|
+ maps.put(account,customers);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("maps",maps);
|
|
|
+ map.put("customerCode","one");//客户编码
|
|
|
+ map.put("CVENCODE","one");//供应商编码
|
|
|
+ map.put("orderNumber","one");//销售订单号2
|
|
|
+ for (int x=0;x<3;x++){//最多循环3次
|
|
|
+ try {
|
|
|
+ if (map.get("account").equals("103")){
|
|
|
+ message+=syPackingListTailoringService.three(main,map);
|
|
|
+ }else if(map.get("account").equals("102")){
|
|
|
+ message+=syPackingListTailoringService.two(main,map);
|
|
|
+ }else if(map.get("account").equals("101")){
|
|
|
+ message+=syPackingListTailoringService.one(main,map);
|
|
|
+ }else{
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ message+=e.getMessage();
|
|
|
+ String msg2=getExceptionStr(e);
|
|
|
+ //System.out.println("成衣批量推送报错");
|
|
|
+ log.info("成衣批量推送报错\t"+msg2);
|
|
|
}
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- message+=e.getMessage();
|
|
|
- String msg2=getExceptionStr(e);
|
|
|
- //System.out.println("成衣批量推送报错");
|
|
|
- log.info("成衣批量推送报错\t"+msg2);
|
|
|
}
|
|
|
}
|
|
|
+ if(message!=null&&message.length()>0&&(message.indexOf("接口")>-1||message.indexOf("失败")>-1)){
|
|
|
+ main.setPushState("2");//推送失败!
|
|
|
+ main.setRecordingError(message);
|
|
|
+ }else if(message.indexOf("成功")>-1){
|
|
|
+ main.setPushState("1");//推送成功!
|
|
|
+ main.setRecordingError("");
|
|
|
+ }else{
|
|
|
+ main.setPushState("3");//推送失败!
|
|
|
+ main.setRecordingError(message);
|
|
|
+ }
|
|
|
+ main.setRecordingStatus(0);
|
|
|
+ syPackingListTailoringService.updateById(main);//修改成衣
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ String msg2= null;
|
|
|
+ try {
|
|
|
+ msg2 = getExceptionStr(e);
|
|
|
+ } catch (IOException ex) {
|
|
|
+ ex.printStackTrace();
|
|
|
+ }
|
|
|
+ //System.out.println("成衣批量推送报错");
|
|
|
+ log.info("成衣批量推送报错\t"+msg2);
|
|
|
}
|
|
|
- //System.out.println("message\t"+message);
|
|
|
- if(message!=null&&message.length()>0&&(message.indexOf("接口")>-1||message.indexOf("失败")>-1)){
|
|
|
- main.setPushState("2");//推送失败!
|
|
|
- main.setRecordingError(message);
|
|
|
- }else if(message.indexOf("成功")>-1){
|
|
|
- main.setPushState("1");//推送成功!
|
|
|
- main.setRecordingError("");
|
|
|
- }else{
|
|
|
- main.setPushState("3");//推送失败!
|
|
|
- main.setRecordingError(message);
|
|
|
- }
|
|
|
- main.setRecordingStatus(0);
|
|
|
- syPackingListTailoringService.updateById(main);//修改成衣
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- String msg2= null;
|
|
|
- try {
|
|
|
- msg2 = getExceptionStr(e);
|
|
|
- } catch (IOException ex) {
|
|
|
- ex.printStackTrace();
|
|
|
- }
|
|
|
- //System.out.println("成衣批量推送报错");
|
|
|
- log.info("成衣批量推送报错\t"+msg2);
|
|
|
}
|
|
|
+ syPackingListTailoringService.updateTimeStatus();
|
|
|
+ }catch (Exception ex){
|
|
|
+ log.info("ex成衣批量推送报错");
|
|
|
+ }finally {
|
|
|
+ isRun = false;
|
|
|
}
|
|
|
- syPackingListTailoringService.updateTimeStatus();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@AutoLog(value = "装箱单成衣批量推送u8")
|
|
|
@@ -1746,6 +1744,10 @@ public class SyPackingListTailoringController implements Job {
|
|
|
@GetMapping(value = "/pushBatch")
|
|
|
public Result pushToU8(String ids) {
|
|
|
Result result=new Result();
|
|
|
+ if (isRun){
|
|
|
+ return result.error500("成衣入库单批量推送已经在执行了");
|
|
|
+ }
|
|
|
+ isRun = true;
|
|
|
try {
|
|
|
//long startTime = System.currentTimeMillis();
|
|
|
if(oConvertUtils.isEmpty(ids)){
|
|
|
@@ -1920,9 +1922,11 @@ public class SyPackingListTailoringController implements Job {
|
|
|
e.printStackTrace();
|
|
|
result.setSuccess(false);
|
|
|
result.error500("操作失败:"+e.getMessage());
|
|
|
+ }finally {
|
|
|
+ isRun = false;
|
|
|
+ syPackingListTailoringService.updateTimeStatus();
|
|
|
+ return result;
|
|
|
}
|
|
|
- syPackingListTailoringService.updateTimeStatus();
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
@AutoLog(value = "获取100个单据号")
|