|
@@ -2,10 +2,12 @@ package org.jeecg.modules.documents.shippingDetails.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.util.oConvertUtils;
|
|
|
import org.jeecg.modules.documents.orderData.entity.SyOrderData;
|
|
|
import org.jeecg.modules.documents.orderData.entity.SyOrderDataItem;
|
|
|
+import org.jeecg.modules.documents.orderData.entity.SyOrderDataVO;
|
|
|
import org.jeecg.modules.documents.orderData.service.impl.SyOrderDataItemServiceImpl;
|
|
|
import org.jeecg.modules.documents.seclarationElements.entity.SyDeclarationElements;
|
|
|
import org.jeecg.modules.documents.seclarationElements.service.ISyDeclarationElementsService;
|
|
@@ -26,6 +28,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.text.ParseException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
@@ -69,7 +72,7 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public SyShippingDetails syShippingDetailsAdd(SyShippingDetails syShippingDetails) {
|
|
|
+ public SyShippingDetails syShippingDetailsAdd(SyShippingDetails syShippingDetails) throws ParseException {
|
|
|
|
|
|
int sort = 1;
|
|
|
List<SyShippingDetailsItem> syShippingDetailsItemList = new ArrayList<>();
|
|
@@ -80,49 +83,93 @@ public class SyShippingDetailsServiceImpl extends ServiceImpl<SyShippingDetailsM
|
|
|
//设置单据号(F2206201305854)
|
|
|
if(oConvertUtils.isEmpty(syId)){
|
|
|
SimpleDateFormat sf = new SimpleDateFormat("yyMMddHHmmSS");
|
|
|
+ SimpleDateFormat sf1 = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
String createTime = sf.format(new Date());
|
|
|
syShippingDetails.setDocumentNo("F"+createTime);
|
|
|
syShippingDetails.setState("0");//状态
|
|
|
- syShippingDetails.setAccount(syShippingDetails.getSyShippingDetailsItemList().get(0).getAccount());//账套
|
|
|
+ String date = sf1.format(new Date());
|
|
|
+ syShippingDetails.setDocumentDate(sf1.parse(date));
|
|
|
+
|
|
|
}
|
|
|
- //新增子表
|
|
|
- List<SyShippingDetailsItem> list = syShippingDetails.getSyShippingDetailsItemList();
|
|
|
-
|
|
|
- if(list.size()!=0){
|
|
|
- for (SyShippingDetailsItem li:list){
|
|
|
-
|
|
|
- li.setSort(sort);
|
|
|
- //设置主表自建
|
|
|
- li.setShippingDetailsId(id);
|
|
|
- li.setId(oConvertUtils.id());
|
|
|
- li.setSurplusQuantity(li.getShipmentQuantity());//剩余数量
|
|
|
- syShippingDetailsItemList.add(li);
|
|
|
- sort++;
|
|
|
- //回写销售订单剩余数量
|
|
|
- SyOrderDataItem orderDataItem = syOrderDataItemService.getById(li.getSyOrderDataItemId());
|
|
|
- if(oConvertUtils.isNotEmpty(orderDataItem)){
|
|
|
- BigDecimal suerBox = orderDataItem.getSurplusNum().subtract(li.getShipmentQuantity());
|
|
|
- orderDataItem.setSurplusNum(suerBox);
|
|
|
- syOrderDataItemService.updateById(orderDataItem);
|
|
|
- }
|
|
|
-
|
|
|
- //获取报关要素ID
|
|
|
- //根据条件查询报关要素信息
|
|
|
- QueryWrapper<SyDeclarationElements> elementsQueryWrapper = new QueryWrapper<>();
|
|
|
- elementsQueryWrapper.eq("inventory_name",li.getInventoryName()).eq("ac_set_no",li.getOmpoAccount()).eq("item_number",li.getItemNumber()).eq("del_flag",0);
|
|
|
- elementsQueryWrapper.orderByDesc("create_time");
|
|
|
- List<SyDeclarationElements> elementsList = syDeclarationElementsService.list(elementsQueryWrapper);
|
|
|
- if(elementsList.size() != 0){
|
|
|
- //获取最新一条ID
|
|
|
- String elementId = elementsList.get(0).getId();
|
|
|
- li.setElementsId(elementId);
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- if(syShippingDetailsItemList.size()!=0){
|
|
|
+ //新增子表
|
|
|
+ int m = 0;
|
|
|
+ //订单子表明细ID集合(单条)
|
|
|
+ List<String> stringList = new ArrayList<>();
|
|
|
+ //分组ID集合
|
|
|
+ List<String> groupIdList = new ArrayList<>();
|
|
|
+
|
|
|
+ QueryWrapper<OrderDataVo> queryWrapper = new QueryWrapper<>();
|
|
|
+ Page<OrderDataVo> page = new Page<OrderDataVo>(1, -1);
|
|
|
+ //查询订单数据
|
|
|
+ List<String> itemId = syShippingDetails.getItemId();
|
|
|
+ for(String ids:itemId){
|
|
|
+ //groupIdList.add(org.jeecg.modules.system.util.oConvertUtils.getId());
|
|
|
+ String itemIdSplit[] = ids.split(",");
|
|
|
+ for (String li:itemIdSplit){
|
|
|
+ stringList.add(li);
|
|
|
+ }
|
|
|
+ queryWrapper.in("b.id",stringList).eq("a.del_flag",0);
|
|
|
+ IPage<OrderDataVo> pageList = syShippingDetailsMapper.displayDetails(page, queryWrapper);
|
|
|
+
|
|
|
+ //清空集合
|
|
|
+ stringList.clear();
|
|
|
+ String gourpid = oConvertUtils.id();
|
|
|
+
|
|
|
+ for (OrderDataVo li:pageList.getRecords()){
|
|
|
+ //实现构造函数方法赋值
|
|
|
+ SyShippingDetailsItem entity = new SyShippingDetailsItem(li);
|
|
|
+ //设置分组ID
|
|
|
+ if(ids.contains(li.getSyOrderDataItemId())){
|
|
|
+ entity.setGroupId(gourpid);
|
|
|
+ }
|
|
|
+ //设置物料成分
|
|
|
+ if(syShippingDetails.getReadyFabric().equals("成衣")){
|
|
|
+ entity.setMaterialComposition(li.getSpecificationAndModel());//取规格型号
|
|
|
+ }else{
|
|
|
+ entity.setMaterialComposition(li.getInventoryName());//取存货名称
|
|
|
+ }
|
|
|
+ //设置排序
|
|
|
+ entity.setSort(sort);
|
|
|
+ //设置主表自建
|
|
|
+ entity.setShippingDetailsId(id);
|
|
|
+ entity.setId(oConvertUtils.id());
|
|
|
+ sort++;
|
|
|
+ //设置报关单价 = 销售单价-佣金
|
|
|
+ BigDecimal yj = li.getYmoney();
|
|
|
+ if(oConvertUtils.isEmpty(yj)){
|
|
|
+ yj = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ if(oConvertUtils.isEmpty(li.getITaxPrice())){
|
|
|
+ li.setITaxPrice(BigDecimal.ZERO);
|
|
|
+ }
|
|
|
+ BigDecimal customsDeclarationUnitPrice = li.getITaxPrice().subtract(yj);
|
|
|
+ entity.setCustomsDeclarationUnitPrice(customsDeclarationUnitPrice);
|
|
|
+
|
|
|
+ //获取报关要素ID
|
|
|
+ //根据条件查询报关要素信息
|
|
|
+ QueryWrapper<SyDeclarationElements> elementsQueryWrapper = new QueryWrapper<>();
|
|
|
+ elementsQueryWrapper.eq("inventory_name",li.getInventoryName()).eq("ac_set_no",li.getOmpoAccount()).eq("item_number",li.getItemNumber()).eq("del_flag",0);
|
|
|
+ elementsQueryWrapper.orderByDesc("create_time");
|
|
|
+ List<SyDeclarationElements> elementsList = syDeclarationElementsService.list(elementsQueryWrapper);
|
|
|
+ if(elementsList.size() != 0){
|
|
|
+ //获取最新一条ID
|
|
|
+ String elementId = elementsList.get(0).getId();
|
|
|
+ entity.setElementsId(elementId);
|
|
|
+ }
|
|
|
+
|
|
|
+ syShippingDetailsItemList.add(entity);
|
|
|
+ //设置主表客户
|
|
|
+ syShippingDetails.setCustomer(li.getCustomerName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(syShippingDetailsItemList.size()!=0){
|
|
|
syShippingDetailsItemService.saveBatch(syShippingDetailsItemList);
|
|
|
+
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
boolean ok = save(syShippingDetails);
|
|
|
if(ok){
|