Explorar el Código

外部报验功能-生成空派单

wangming hace 1 año
padre
commit
bf3ef477a8

+ 46 - 7
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxOutsideInspectionItpServiceImpl.java

@@ -27,7 +27,6 @@ import com.rongwei.rwcommon.base.R;
 import com.rongwei.rwcommon.base.exception.CustomException;
 import com.rongwei.rwcommon.utils.SecurityUtil;
 import com.rongwei.rwcommon.utils.StringUtils;
-import com.rongwei.rwcommon.vo.MailDo;
 import com.rongwei.rwcommon.vo.generalsql.MasterSlaveUpdateVo;
 import com.rongwei.rwcommonentity.commonservers.domain.SysFileItemDo;
 import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
@@ -39,12 +38,9 @@ import org.springframework.transaction.annotation.Isolation;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.ResourceUtils;
 
-import javax.servlet.ServletOutputStream;
 import javax.servlet.http.HttpServletResponse;
 import java.io.*;
-import java.net.URL;
 import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 /**
@@ -111,12 +107,13 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         }
         String[] inspectionContents = itpDo.getInspectioncontent().split(","); //报验点
 
-//        if(structureNames.length * inspectionContents.length < 1) {
-//            return ;
-//        }
         //只有一个构件和报验点时
         //不需要拆单
         if(structureNames.length * inspectionContents.length <= 1) {
+
+            //生成空派单
+            genEmptyDispatch(id);
+
             //存在报验单号,则不再生成
             if(ObjectUtil.isNotEmpty(itpDo.getInspectioncode())) {
                 return ;
@@ -129,6 +126,7 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
         }
 
         List<ZhcxOutsideInspectionItpDo> insertList = new ArrayList<>();
+        List<ZhcxOutsideInspectionItpSupervisionDispatchDo> insertDispatchList = new ArrayList<>();
         List<ZhcxOutsideInspectionItpDo> updateList = new ArrayList<>();
         List<String> newItpIdList = new ArrayList<>();
 
@@ -143,6 +141,9 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
                     itpDo.setInspectioncode(genCode());
 //                    itpDo.setStructureid(structureIds[m]);
                     updateList.add(itpDo);
+
+                    //生成空派单数据
+                    genEmptyDispatch(id);
                     continue;
                 }
 
@@ -156,13 +157,25 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
                 insertList.add(entity);
                 newItpIdList.add(entity.getId());
 
+                //空派单
+                ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
+                dispatchDo.setId(SecurityUtil.getUUID());
+                dispatchDo.setDeleted("0");
+                dispatchDo.setItpid(entity.getId());
+                insertDispatchList.add(dispatchDo);
+
             }
         }
 
+        //报验单明细
         insertChildren(itpDo, newItpIdList);
 
+        //报验单
         updateBatchById(updateList);
         saveBatch(insertList);
+
+        //空派单数据
+        dispatchService.saveBatch(insertDispatchList);
     }
 
     @Override
@@ -451,6 +464,32 @@ public class ZhcxOutsideInspectionItpServiceImpl extends ServiceImpl<ZhcxOutside
 
     }
 
+    /**
+     * 生成派单
+     * 1、校验是否已存在
+     * 2、不存在新增
+     *
+     * @param itpId
+     */
+    private void genEmptyDispatch(String itpId) {
+        //派单
+        LambdaQueryWrapper<ZhcxOutsideInspectionItpSupervisionDispatchDo> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(ZhcxOutsideInspectionItpSupervisionDispatchDo::getItpid, itpId);
+        queryWrapper.eq(ZhcxOutsideInspectionItpSupervisionDispatchDo::getDeleted, "0");
+        int count = dispatchService.count(queryWrapper);
+
+        if(count > 0) {
+            return ;
+        }
+
+        ZhcxOutsideInspectionItpSupervisionDispatchDo dispatchDo = new ZhcxOutsideInspectionItpSupervisionDispatchDo();
+        dispatchDo.setId(SecurityUtil.getUUID());
+        dispatchDo.setDeleted("0");
+        dispatchDo.setItpid(itpId);
+
+        dispatchService.save(dispatchDo);
+    }
+
     /**
      * 获取取消发送邮件内容
      *