浏览代码

内部报验功能

wangming 1 年之前
父节点
当前提交
de35025892

+ 6 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxInsideInspectionDispatchService.java

@@ -13,4 +13,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZhcxInsideInspectionDispatchService extends IService<ZhcxInsideInspectionDispatchDo> {
 
+    /**
+     * 生成空派单
+     *
+     * @param insideId
+     */
+    void genEmptyDispatch(String insideId);
 }

+ 7 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxInsideInspectionOperLogService.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.service;
 
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionOperLogDo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.dto.InsideOperLogDto;
 
 /**
  * <p>
@@ -13,4 +14,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZhcxInsideInspectionOperLogService extends IService<ZhcxInsideInspectionOperLogDo> {
 
+    /**
+     * 操作记录
+     *
+     * @param req
+     */
+    void saveOperLog(InsideOperLogDto req);
 }

+ 7 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/ZhcxInsideInspectionService.java

@@ -2,6 +2,7 @@ package com.rongwei.bscommon.sys.service;
 
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
 
 /**
  * <p>
@@ -13,4 +14,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
  */
 public interface ZhcxInsideInspectionService extends IService<ZhcxInsideInspectionDo> {
 
+    /**
+     * 发起
+     *
+     * @param req
+     */
+    void launch(InsideInspectionOperRequest req);
 }

+ 27 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxInsideInspectionDispatchServiceImpl.java

@@ -1,9 +1,12 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDispatchDo;
 import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionDispatchDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionDispatchService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.rwcommon.utils.SecurityUtil;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +20,28 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZhcxInsideInspectionDispatchServiceImpl extends ServiceImpl<ZhcxInsideInspectionDispatchDao, ZhcxInsideInspectionDispatchDo> implements ZhcxInsideInspectionDispatchService {
 
+    /**
+     * 生成空派单
+     *
+     * @param insideId
+     */
+    @Override
+    public void genEmptyDispatch(String insideId) {
+
+        //已经存在不重复生成
+        LambdaQueryWrapper<ZhcxInsideInspectionDispatchDo> queryWrapper = Wrappers.lambdaQuery();
+        queryWrapper.eq(ZhcxInsideInspectionDispatchDo::getInsideid, insideId);
+        queryWrapper.eq(ZhcxInsideInspectionDispatchDo::getDeleted, "0");
+        int count = count(queryWrapper);
+        if(count > 0) {
+            return ;
+        }
+
+        //生成空派单
+        ZhcxInsideInspectionDispatchDo dispatchDo = new ZhcxInsideInspectionDispatchDo();
+        dispatchDo.setId(SecurityUtil.getUUID());
+        dispatchDo.setDeleted("0");
+        dispatchDo.setInsideid(insideId);
+        save(dispatchDo);
+    }
 }

+ 28 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxInsideInspectionOperLogServiceImpl.java

@@ -4,6 +4,8 @@ import com.rongwei.bsentity.domain.ZhcxInsideInspectionOperLogDo;
 import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionOperLogDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionOperLogService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bsentity.dto.InsideOperLogDto;
+import com.rongwei.rwcommon.utils.SecurityUtil;
 import org.springframework.stereotype.Service;
 
 /**
@@ -17,4 +19,30 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZhcxInsideInspectionOperLogServiceImpl extends ServiceImpl<ZhcxInsideInspectionOperLogDao, ZhcxInsideInspectionOperLogDo> implements ZhcxInsideInspectionOperLogService {
 
+    /**
+     * 操作记录
+     *
+     * @param req
+     */
+    @Override
+    public void saveOperLog(InsideOperLogDto req) {
+
+        ZhcxInsideInspectionOperLogDo entity = new ZhcxInsideInspectionOperLogDo();
+        entity.setId(SecurityUtil.getUUID());
+        entity.setDeleted("0");
+
+
+        entity.setInsideid(req.getId());
+        entity.setOpertime(req.getOperTime());
+        entity.setOpertype(req.getOperType());
+        entity.setOpersource(req.getLaunchSource());
+        entity.setOpertime(req.getOperTime());
+
+        entity.setOperuserid(req.getOperUser().getId());
+        entity.setOperusername(req.getOperUser().getName());
+
+        save(entity);
+    }
+
+
 }

+ 80 - 0
business-common/src/main/java/com/rongwei/bscommon/sys/service/impl/ZhcxInsideInspectionServiceImpl.java

@@ -1,11 +1,23 @@
 package com.rongwei.bscommon.sys.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionDispatchService;
+import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionOperLogService;
+import com.rongwei.bscommon.sys.utils.ZhcxCommon;
 import com.rongwei.bsentity.domain.ZhcxInsideInspectionDo;
 import com.rongwei.bscommon.sys.dao.ZhcxInsideInspectionDao;
 import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
+import com.rongwei.bsentity.dto.InsideOperLogDto;
+import com.rongwei.commonservice.serial.service.SysSerialNumberService;
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import com.rongwei.rwcommonentity.commonservers.vo.SysSerialVo;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.Date;
+
 /**
  * <p>
  * 内部报验-报验管理 服务实现类
@@ -17,4 +29,72 @@ import org.springframework.stereotype.Service;
 @Service
 public class ZhcxInsideInspectionServiceImpl extends ServiceImpl<ZhcxInsideInspectionDao, ZhcxInsideInspectionDo> implements ZhcxInsideInspectionService {
 
+    @Autowired
+    private ZhcxInsideInspectionDispatchService dispatchService;
+
+    @Autowired
+    private SysSerialNumberService serialNumberService;
+
+    @Autowired
+    private ZhcxInsideInspectionOperLogService zhcxInsideInspectionOperLogService;
+
+    @Autowired
+    private ZhcxCommon zhcxCommon;
+
+    /**
+     * 保存后操作
+     *
+     * @param req
+     */
+    @Override
+    public void launch(InsideInspectionOperRequest req) {
+        ZhcxInsideInspectionDo inspectionDo = getById(req.getId());
+        //生成报验单号
+        genInspectionCode(inspectionDo);
+        //生成空派单信息
+        dispatchService.genEmptyDispatch(req.getId());
+
+        //生成操作记录
+        SysUserVo user = zhcxCommon.getCurrentUser();
+        InsideOperLogDto operLogDto = InsideOperLogDto.builder()
+                .id(req.getId())
+                .operType("5")
+                .launchSource(ObjectUtil.isEmpty(req.getLaunchSource()) ? "mobile" : req.getLaunchSource())
+                .build();
+        operLogDto.setOperUser(user);
+        operLogDto.setOperTime(new Date());
+        zhcxInsideInspectionOperLogService.saveOperLog(operLogDto);
+    }
+
+    /**
+     * 生成报验单号
+     *
+     * @param inspectionDo
+     */
+    private void genInspectionCode(ZhcxInsideInspectionDo inspectionDo) {
+        //存在报验单号,则不再生成
+        if(ObjectUtil.isNotEmpty(inspectionDo.getInspectioncode())) {
+            return ;
+        }
+
+        ZhcxInsideInspectionDo entity = new ZhcxInsideInspectionDo();
+        entity.setId(inspectionDo.getId());
+        entity.setInspectioncode(genCode());
+        updateById(entity);
+    }
+
+    /**
+     * 生成单号
+     *
+     * @return
+     */
+    private String genCode() {
+        SysSerialVo sysSerialVo = new SysSerialVo();
+        sysSerialVo.setRuleTemplateStr("N@{date:yyyyMMdd}@{serialNumber:#0000}");
+        sysSerialVo.setModulecode("ZHCX_INSIDE_INSPECTION");
+        sysSerialVo.setIfautomaticreset("y");
+        sysSerialVo.setResetrule("date:yyyyMMdd");
+        sysSerialVo.setInitValue(0L);
+        return serialNumberService.getCodeByTemplate(sysSerialVo);
+    }
 }

+ 11 - 0
business-entity/src/main/java/com/rongwei/bsentity/domain/ZhcxInsideInspectionOperLogDo.java

@@ -65,5 +65,16 @@ public class ZhcxInsideInspectionOperLogDo extends BaseDo {
     @TableField("OPERTIME")
     private Date opertime;
 
+    /**
+     * 操作用户id
+     */
+    @TableField("OPERUSERID")
+    private String operuserid;
+
+    /**
+     * 操作用户姓名
+     */
+    @TableField("OPERUSERNAME")
+    private String operusername;
 
 }

+ 24 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/InsideInspectionOperRequest.java

@@ -0,0 +1,24 @@
+package com.rongwei.bsentity.dto;
+
+import lombok.*;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class InsideInspectionOperRequest {
+
+    /**
+     * 内部报验单id
+     */
+    private String id;
+
+    /**
+     * 发起源
+     *
+     * pc
+     * mobile
+     */
+    private String launchSource;
+}

+ 30 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/InsideOperLogDto.java

@@ -0,0 +1,30 @@
+package com.rongwei.bsentity.dto;
+
+import lombok.*;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+@Builder
+public class InsideOperLogDto extends OperDto {
+
+    /**
+     * 内部报验单id
+     */
+    private String id;
+
+    /**
+     * 发起员
+     *
+     * pc
+     * mobile
+     */
+    private String launchSource;
+
+    /**
+     * 操作类型
+     *
+     */
+    private String operType;
+}

+ 23 - 0
business-entity/src/main/java/com/rongwei/bsentity/dto/OperDto.java

@@ -0,0 +1,23 @@
+package com.rongwei.bsentity.dto;
+
+import com.rongwei.rwadmincommon.system.vo.SysUserVo;
+import lombok.*;
+
+import java.util.Date;
+
+@Setter
+@Getter
+@NoArgsConstructor
+@AllArgsConstructor
+public class OperDto {
+
+    /**
+     * 操作人
+     */
+    private SysUserVo operUser;
+
+    /**
+     * 操作时间
+     */
+    private Date operTime;
+}

+ 21 - 1
business-server/src/main/java/com/rongwei/bsserver/controller/ZhcxInsideInspectionController.java

@@ -1,6 +1,12 @@
 package com.rongwei.bsserver.controller;
 
 
+import com.rongwei.bscommon.sys.service.ZhcxInsideInspectionService;
+import com.rongwei.bsentity.dto.InsideInspectionOperRequest;
+import com.rongwei.rwcommon.base.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -13,8 +19,22 @@ import org.springframework.web.bind.annotation.RestController;
  * @since 2024-05-21
  */
 @RestController
-@RequestMapping("/zhcxInsideInspection")
+@RequestMapping("/inside/inspection")
 public class ZhcxInsideInspectionController {
 
+    @Autowired
+    private ZhcxInsideInspectionService zhcxInsideInspectionService;
+
+    /**
+     * 发起
+     *
+     * @param req
+     * @return
+     */
+    @PostMapping("/launch")
+    public R launch(@RequestBody InsideInspectionOperRequest req){
+        zhcxInsideInspectionService.launch(req);
+        return R.ok();
+    }
 }