瀏覽代碼

装箱单增加 批量提交和批量取消功能

huxy 2 年之前
父節點
當前提交
57f03cf847

+ 72 - 29
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/controller/SyPreAssembledPackingListController.java

@@ -4,7 +4,6 @@ import java.io.File;
 import java.io.IOException;
 import java.text.SimpleDateFormat;
 import java.util.*;
-import java.util.stream.Collectors;
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
@@ -21,11 +20,6 @@ import org.jeecg.modules.openApi.service.IDxpDataPlanService;
 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.def.TemplateExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.entity.ImportParams;
 
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
@@ -35,6 +29,11 @@ import org.jeecg.modules.spapl.entity.SyPreAssembledPackingList;
 import org.jeecg.modules.spapl.vo.SyPreAssembledPackingListPage;
 import org.jeecg.modules.spapl.service.ISyPreAssembledPackingListService;
 import org.jeecg.modules.spapl.service.ISyPreAssembledPackingListItemService;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.def.TemplateExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.entity.TemplateExportParams;
 import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
 import org.jeecgframework.poi.excel.view.JeecgTemplateExcelView;
@@ -583,6 +582,42 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 		 return result;
 	 }
 
+	/**
+	 * 批量取消提交
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "预装箱单主表-批量取消提交")
+	@ApiOperation(value="预装箱单主表-批量取消提交", notes="预装箱单主表-批量取消提交")
+	@RequestMapping(value = "/cancelSubmitBatch", method = {RequestMethod.GET})
+	public Result<?> cancelSubmitBatch(@RequestParam(value = "ids",required = true) String[] ids) {
+		Result<String> result=new Result<>();
+		try{
+			if(oConvertUtils.isEmpty(ids)){
+				result.setMessage("请至少选中一条单据!");
+				result.setSuccess(false);
+				return result;
+			}
+			String str= syPreAssembledPackingListService.cancelSubmitBatch(ids);//修改提交状态
+			if(str.length()>0){
+				result.setMessage("该数据已被成衣-装箱单参照!");
+				result.setSuccess(false);
+				result.setResult(str);//返回已被参照的id
+				result.setCode(111);
+				return result;
+			}
+			result.setMessage("成功取消提交!");
+			result.setSuccess(true);
+			return result;
+		}catch (Exception ex){
+			ex.printStackTrace();
+			log.error("取消提交失败:" + ex.getMessage());
+			result.error500("取消提交失败:" + ex.getMessage());
+		}
+		return result;
+	}
+
 	/**
 	 * 通过id删除
 	 *
@@ -737,55 +772,63 @@ public class SyPreAssembledPackingListController extends JeecgController<SyPreAs
 	public ModelAndView exportXls(HttpServletRequest request, SyPreAssembledPackingList syPreAssembledPackingList) throws Exception {
 
 	  	// Step.1 组装查询条件
-		/*QueryWrapper<SyPreAssembledPackingList> queryWrapper = QueryGenerator.initQueryWrapper(syPreAssembledPackingList, request.getParameterMap());
+		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);
+			QueryWrapper queryWrapper1=new QueryWrapper();
+			queryWrapper1.eq("sy_Pre_Assembled_Packing_List_Id",temp.getId());//获取主表id
+			queryWrapper1.eq("del_flag","0");//未删除数据
+			List<SyPreAssembledPackingListItem> items = syPreAssembledPackingListItemService.list(queryWrapper1);
+			temp.setSyPreAssembledPackingListItemList(items);
 		}
 		 // return exportXlsSheet2(request,SyPreAssembledPackingList.class,syPreAssembledPackingListList,"预装箱单",1);
-		  String load="/static/paking.xlsx";//文件名
+		  String load= "/static/test.xlsx";//文件名
 		  double total = syPreAssembledPackingListList.size();//总条数
 		  int count = (int)Math.ceil(total/1);//每条sheet分几条数据
 		  File filePath=new File(ResourceUtils.getURL("classpath:").getPath());//获取路径
 		  File file=new File(filePath,load);
-		  TemplateExportParams templateExcelConstants=new TemplateExportParams(file.getAbsolutePath());
+		  TemplateExportParams templateExcelConstants=new TemplateExportParams(file.getAbsolutePath(),true,"测试");
+
+		  //templateExcelConstants.setTempParams("true");
 		  List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
 		  Map<String, Object> maps = new HashMap<String, Object>();
 		  for (int i = 1; i <=count ; i++) {
-			  List<SyPreAssembledPackingList> exportList = new ArrayList<SyPreAssembledPackingList>();
+			  System.out.println("循环了"+i+"次");
+			 // List<SyPreAssembledPackingList exportList = new ArrayList<SyPreAssembledPackingList>();
+			  SyPreAssembledPackingList exportList = new SyPreAssembledPackingList();
+			  exportList=syPreAssembledPackingListList.get(i-1);
+
+			  //exportList.add(syPreAssembledPackingListList.get(i-1));
 			  //过滤选中数据
-			  String selections = request.getParameter("selections");
-			  if (oConvertUtils.isNotEmpty(selections)) {
+			 // String selections = request.getParameter("selections");
+			  /*if (oConvertUtils.isNotEmpty(selections)) {
 				  List<String> selectionList = Arrays.asList(selections.split(","));
 				  exportList = syPreAssembledPackingListList.stream().filter(item -> selectionList.contains(getId(item))).collect(Collectors.toList());
 			  }
 			  else {
 				  exportList.add(syPreAssembledPackingListList.get(i-1));
-			  }
-			  ExportParams exportParams=new ExportParams("预装箱单报表", "导出人:admin" , "预装箱单"+i,"/opt/upFiles");//sysUser.getRealname()
-			  System.out.println("ExcelType.XSSF为:\t"+ ExcelType.XSSF);
+			  }*/
+			 ExportParams exportParams=new ExportParams("预装箱单报表", "导出人:admin" , "预装箱单"+i);//sysUser.getRealname()
+			  //System.out.println("ExcelType.XSSF为:\t"+ ExcelType.XSSF);
 			  exportParams.setType(ExcelType.XSSF);
+			  // map.put("title",exportParams);//表格Title
+			  //System.out.println("NormalExcelConstants.MAP_LIST的值为\n"+ NormalExcelConstants.MAP_LIST);
 			  Map<String, Object> map = new HashMap<String, Object>();
-			  map.put("title",exportParams);//表格Title
-			  map.put(NormalExcelConstants.PARAMS,templateExcelConstants);//表格Title
-			  map.put(NormalExcelConstants.CLASS,Object.class);//表格对应实体
-			  map.put(NormalExcelConstants.MAP_LIST, exportList);//数据集合
-			  System.out.println("NormalExcelConstants.MAP_LIST的值为\n"+NormalExcelConstants.MAP_LIST);
-			  map.put("orderNumber","订单号");
-			  map.put("id","主键");
-			  map.put("styleNo","款号");
+			  map.put(NormalExcelConstants.CLASS,SyPreAssembledPackingList.class);//表格对应实体
+			  map.put(NormalExcelConstants.PARAMS,exportParams);//表格Title
+			  map.put(NormalExcelConstants.DATA_LIST, exportList);//数据集合
 			  listMap.add(map);
+			  //maps.put("main",exportList);
 		  }
-		  maps.put("test",listMap);
 		  ModelAndView mv = new ModelAndView(new JeecgTemplateExcelView());
-		  maps.put("orderNumber","订单号");
+		  maps.put("orderNumber",listMap);
+		  System.out.println("maps的值为:\n"+maps.get("orderNumber"));
+		  mv.addObject(TemplateExcelConstants.FILE_NAME,"预装箱单模板导出测试");
 		  mv.addObject(TemplateExcelConstants.PARAMS,templateExcelConstants);
 		  mv.addObject(TemplateExcelConstants.MAP_DATA, maps);
-		  return mv;*/
-		  return null;
+		  return mv;
 	}
 
 	  /**

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/ISyPreAssembledPackingListService.java

@@ -96,6 +96,8 @@ public interface ISyPreAssembledPackingListService extends IService<SyPreAssembl
 	 */
 	public String submitBatch(String [] ids);
 
+	public String cancelSubmitBatch(String [] ids);
+
 	public String updateShipping();
 
 	/**

+ 30 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/service/impl/SyPreAssembledPackingListServiceImpl.java

@@ -29,6 +29,7 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import javax.annotation.Resource;
 import java.io.Serializable;
@@ -196,7 +197,7 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 
 		syPreAssembledPackingList.setDelFlag("0");//删除状态默认为0
 		syPreAssembledPackingList.setPushStatus("0");//推送状态默认为0
-		if(oConvertUtils.isEmpty(syPreAssembledPackingList.getStatus())||syPreAssembledPackingList.getStatus().equals("1")){
+		if(oConvertUtils.isEmpty(syPreAssembledPackingList.getStatus())||!syPreAssembledPackingList.getStatus().equals("1")){
 			syPreAssembledPackingList.setStatus("0");//单据状态默认为0
 		}
 		syPreAssembledPackingListMapper.insert(syPreAssembledPackingList);//往主表添加数据
@@ -398,6 +399,34 @@ public class SyPreAssembledPackingListServiceImpl extends ServiceImpl<SyPreAssem
 		return "提交成功";
 	}
 
+	@Override
+	@Transactional
+	public String cancelSubmitBatch(String[] ids) {
+		String str="";
+		try{
+			for (String id : ids){
+				SyPreAssembledPackingList syPreAssembledPackingList=syPreAssembledPackingListMapper.selectById(id);
+				if(syPreAssembledPackingList.getIsReference()==2){
+					str+=syPreAssembledPackingList.getId()+",";//获取已被参照的id
+				}
+				syPreAssembledPackingList.setStatus("0");//取消提交
+				syPreAssembledPackingListMapper.updateById(syPreAssembledPackingList);
+			}
+			System.out.println("str的长度为:\t"+str.length());
+			if(str.length()>0){
+				throw new JeecgBootException("数据已被成衣工厂参照");
+			}
+		}catch (Exception e){
+			log.error(e.getMessage());
+			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
+		}finally {
+			if(str.length()==0){
+				return str;
+			}
+			return str.substring(0,str.length()-1);
+		}
+	}
+
 	/**
 	 * 根据出运明细id,补上一部分缺失的数据
 	 * @return

+ 4 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/spapl/vo/SyPreAssembledPackingListVo.java

@@ -186,6 +186,9 @@ public class SyPreAssembledPackingListVo {
 //	@ApiModelProperty(value = "数量(按合并规则累计)")
 //	@Excel(name = "数量(按合并规则累计)", width = 20)
 //	private java.math.BigDecimal totalQuantity;
-
+	/**是否被参照(0:无,1:被预托书参照,2:被装箱单参照)*/
+	//@Excel(name = "是否被参照(0:无,1:被预托书参照,2:被装箱单参照)", width = 15)
+	@ApiModelProperty(value = "是否被参照(0:无,1:被预托书参照,2:被装箱单参照)")
+	private Integer isReference;
 	
 }

+ 70 - 13
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/controller/SyPackingListTailoringController.java

@@ -255,32 +255,89 @@ public class SyPackingListTailoringController {
 	 }
 
 	 /**
-	  * 提交
+	  * 批量提交
 	  *
-	  * @param id
+	  * @param ids
 	  * @return
 	  */
-	 @AutoLog(value = "装箱单成衣-提交")
-	 @ApiOperation(value="装箱单成衣-提交", notes="装箱单成衣-提交")
-	 @RequestMapping(value = "/submit", method = {RequestMethod.GET})
-	 public Result<?> submit(String id) {
+	 @AutoLog(value = "装箱单成衣-批量提交")
+	 @ApiOperation(value="装箱单成衣-批量提交", notes="装箱单成衣-批量提交")
+	 @RequestMapping(value = "/submitBatch", method = {RequestMethod.GET})
+	 public Result<?> submitBatch(@RequestParam(value = "ids",required = true) String[] ids) {
 	 	Result result=new Result();
-	 	if(oConvertUtils.isEmpty(id)){
-	 		result.setMessage("id为空");
+	 	if(oConvertUtils.isEmpty(ids)){
+	 		result.setMessage("请至少选中一条数据再提交");
 	 		result.setSuccess(false);
 			return result;
 	 	}
-	 	SyPackingListTailoring syPackingListTailoring=syPackingListTailoringService.getById(id);
-	 	if(syPackingListTailoring==null){
-			result.setMessage("未查到id对应的数据");
+	 	boolean bool=syPackingListTailoringService.submitBatch(ids);
+	 	if(bool==false){
+			result.setMessage("提交失败,数据库无数据!");
 			result.setSuccess(false);
 			return result;
 		}
-	 	syPackingListTailoring.setStatus("1");//修改为已提交
-	 	syPackingListTailoringService.updateById(syPackingListTailoring);
+
+		 result.setMessage("提交成功");
+		 result.setSuccess(true);
 	 	return result;
 	 }
 
+	 /**
+	  * 批量取消提交
+	  *
+	  * @param ids
+	  * @return
+	  */
+	 @AutoLog(value = "装箱单成衣-批量取消提交")
+	 @ApiOperation(value="装箱单成衣-批量取消提交", notes="装箱单成衣-批量取消提交")
+	 @RequestMapping(value = "/cancelSubmitBatch", method = {RequestMethod.GET})
+	 public Result<?> cancelSubmitBatch(@RequestParam(value = "ids",required = true) String[] ids) {
+		 Result result=new Result();
+		 if(oConvertUtils.isEmpty(ids)){
+			 result.setMessage("请至少选中一条数据再提交");
+			 result.setSuccess(false);
+			 return result;
+		 }
+		 String str=syPackingListTailoringService.cancelSubmitBatch(ids);
+		 if(str.length()>0){
+			 result.setMessage("取消提交失败,已被托书参照并提交");
+			 result.setResult(str);
+			 result.setCode(111);
+			 result.setSuccess(false);
+			 return result;
+		 }
+		 result.setMessage("取消提交成功");
+		 result.setSuccess(true);
+		 return result;
+	 }
+
+	 /**
+	  * 提交
+	  *
+	  * @param id
+	  * @return
+	  */
+	 @AutoLog(value = "装箱单成衣-提交")
+	 @ApiOperation(value="装箱单成衣-提交", notes="装箱单成衣-提交")
+	 @RequestMapping(value = "/submit", method = {RequestMethod.GET})
+	 public Result<?> submit(String id) {
+		 Result result=new Result();
+		 if(oConvertUtils.isEmpty(id)){
+			 result.setMessage("id为空");
+			 result.setSuccess(false);
+			 return result;
+		 }
+		 SyPackingListTailoring syPackingListTailoring=syPackingListTailoringService.getById(id);
+		 if(syPackingListTailoring==null){
+			 result.setMessage("未查到id对应的数据");
+			 result.setSuccess(false);
+			 return result;
+		 }
+		 syPackingListTailoring.setStatus("1");//修改为已提交
+		 syPackingListTailoringService.updateById(syPackingListTailoring);
+		 return result;
+	 }
+
 	 /**
 	  * 取消提交
 	  *

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/SyPackingListTailoringMapper.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Param;
 import org.jeecg.modules.documents.shippingDetails.entity.VO.SyShippingDetailsVo;
+import org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrder;
 import org.jeecg.modules.splt.entity.SyPackingListTailoring;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.splt.vo.SyPackingListTailoringVo;
@@ -24,4 +25,6 @@ public interface SyPackingListTailoringMapper extends BaseMapper<SyPackingListTa
     public void deleteByMainId(String id);
 
     public IPage<SyPackingListTailoringVo> selectList2(IPage<SyPackingListTailoringVo> page, @Param("ew") QueryWrapper<SyPackingListTailoringVo> queryWrapper);
+
+    public SyShippingOrder querySyShippingOrder(String SyPackingListTailoringId);
 }

+ 6 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/mapper/xml/syPackingListTailoringMapper.xml

@@ -136,4 +136,10 @@
        from  sy_packing_list_tailoring a
        where id=#{value}
     </select>
+
+    <select id="querySyShippingOrder" resultType="org.jeecg.modules.documents.syShippingOrder.entity.SyShippingOrder">
+        SELECT * FROM Sy_Shipping_Order
+        WHERE ID IN (SELECT sy_Shipping_Order_Item_Id FROM Sy_Shipping_Order_ITEM
+        WHERE tailoring_Fabric_Id=#{value} AND del_flag=0) and the_Documents_State=1
+    </select>
 </mapper>

+ 5 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/ISyPackingListTailoringService.java

@@ -74,4 +74,9 @@ public interface ISyPackingListTailoringService extends IService<SyPackingListTa
 
 	//同步上游数据
 	SyPackingListTailoring getOrderNumber();
+
+	//批量提交
+	boolean submitBatch(String [] ids);
+
+	String cancelSubmitBatch(String [] ids);
 }

+ 55 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/splt/service/impl/SyPackingListTailoringServiceImpl.java

@@ -28,6 +28,8 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
+import org.springframework.transaction.interceptor.TransactionAspectSupport;
+
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
@@ -370,4 +372,57 @@ public class SyPackingListTailoringServiceImpl extends ServiceImpl<SyPackingList
 		}
 		return null;
 	}
+
+	@Override
+	@Transactional
+	public boolean submitBatch(String[] ids) {
+		boolean bool=false;
+		try{
+			for (String id : ids){
+				SyPackingListTailoring syPackingListTailoring=syPackingListTailoringMapper.selectById(id);
+				if(syPackingListTailoring==null){
+					throw new JeecgBootException("数据库无数据");
+				}
+				syPackingListTailoring.setStatus("1");//已提交
+				syPackingListTailoringMapper.updateById(syPackingListTailoring);
+			}
+			bool=true;
+		}catch (Exception e){
+			log.error(e.getMessage());
+			bool=false;
+		}finally {
+			return bool;
+		}
+	}
+
+	@Override
+	@Transactional
+	public String cancelSubmitBatch(String[] ids) {
+		String str="";
+		try{
+			for (String id : ids){
+				SyPackingListTailoring syPackingListTailoring=syPackingListTailoringMapper.selectById(id);
+				if (syPackingListTailoring.getIsReference()>0){//至少已被参照的数据进行查询
+					SyShippingOrder syShippingOrder=syPackingListTailoringMapper.querySyShippingOrder(id);
+					if(syShippingOrder!=null){
+						str+=id+",";
+					}
+				}
+				syPackingListTailoring.setStatus("0");//取消提交
+				syPackingListTailoringMapper.updateById(syPackingListTailoring);
+			}
+			System.out.println("str的长度为:\t"+str.length());
+			if(str.length()>0){
+				throw new JeecgBootException("已被托书参照并提交");
+			}
+		}catch (Exception e){
+			log.error(e.getMessage());
+			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();//事务回滚
+		}finally {
+			if(str.length()==0){
+				return str;
+			}
+			return str.substring(0,str.length()-1);
+		}
+	}
 }