Forráskód Böngészése

新增设备发货管理列表

wangliang 1 éve
szülő
commit
562129933a

+ 6 - 4
sop-api/install/mysql/init/init.sql

@@ -386,7 +386,8 @@ CREATE TABLE `sys_device_brand` (
                                     `create_time` bigint(20) DEFAULT NULL COMMENT '创建时间',
                                     `update_id` bigint(20) DEFAULT NULL COMMENT '更新人id',
                                     `update_time` bigint(20) DEFAULT NULL COMMENT '更新时间',
-                                    PRIMARY KEY (`id`)
+                                    PRIMARY KEY (`id`),
+                                    UNIQUE KEY `sys_device_brand_un_brand` (`brand`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备品牌表';
 
 -- ----------------------------
@@ -401,7 +402,8 @@ CREATE TABLE `sys_device_model` (
                                     `create_time` bigint(20) DEFAULT NULL COMMENT '创建时间',
                                     `update_id` bigint(20) DEFAULT NULL COMMENT '更新人id',
                                     `update_time` bigint(20) DEFAULT NULL COMMENT '更新时间',
-                                    PRIMARY KEY (`id`)
+                                    PRIMARY KEY (`id`),
+                                    UNIQUE KEY `sys_device_model_un` (`brand_id`,`model`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='设备品牌型号表';
 
 -- ----------------------------
@@ -1530,7 +1532,7 @@ CREATE TABLE `t_b_device_delivery` (
                                        `service_id` bigint DEFAULT NULL COMMENT '服务单元id',
                                        `crm_no` varchar(100) DEFAULT NULL COMMENT 'crm单号',
                                        `sop_no` varchar(100) DEFAULT NULL COMMENT 'sop单号',
-                                       `device_no` varchar(50) NOT NULL COMMENT '设备编号',
+                                       `serial_no` varchar(50) NOT NULL COMMENT '设备序列号',
                                        `usage_type` varchar(45) NOT NULL COMMENT '用途类型,PROJECT:项目,OTHER:其它',
                                        `supplier_id` bigint DEFAULT NULL COMMENT '供应商id',
                                        `num` int DEFAULT NULL COMMENT '数量',
@@ -1545,7 +1547,7 @@ CREATE TABLE `t_b_device_delivery` (
                                        `deliver_user_id` bigint DEFAULT NULL COMMENT '发货人id',
                                        `receive_time` bigint DEFAULT NULL COMMENT '签收时间',
                                        `receive_user_id` bigint DEFAULT NULL COMMENT '签收人id',
-                                       `enable` tinyint DEFAULT NULL COMMENT '是否启用,0:停用,1:启用',
+                                       `enable` tinyint DEFAULT '1' NULL COMMENT '是否启用,0:停用,1:启用',
                                        `create_id` bigint DEFAULT NULL COMMENT '创建人id',
                                        `create_time` bigint DEFAULT NULL COMMENT '创建时间',
                                        `update_id` bigint DEFAULT NULL COMMENT '更新人id',

+ 38 - 3
sop-api/src/main/java/com/qmth/sop/server/api/TBDeviceDeliveryController.java

@@ -1,14 +1,17 @@
 package com.qmth.sop.server.api;
 
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.params.TBDeviceDeliveryParam;
+import com.qmth.sop.business.bean.result.ProjectExchangeResult;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
 import com.qmth.sop.business.service.TBDeviceDeliveryService;
 import com.qmth.sop.common.annotation.OperationLog;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.DeviceDeliveryStatusEnum;
+import com.qmth.sop.common.enums.DeviceUsageTypeEnum;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.LogTypeEnum;
 import com.qmth.sop.common.util.Result;
@@ -22,6 +25,8 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
 import javax.validation.Valid;
+import javax.validation.constraints.Max;
+import javax.validation.constraints.Min;
 import java.util.List;
 import java.util.Optional;
 
@@ -41,16 +46,46 @@ public class TBDeviceDeliveryController {
     @Resource
     TBDeviceDeliveryService tbDeviceDeliveryService;
 
-    @ApiOperation(value = "设备发货修改接口")
+    @ApiOperation(value = "项目变更计划列表接口")
+    @RequestMapping(value = "/list", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = ProjectExchangeResult.class)})
+    public Result list(@ApiParam(value = "服务单元id") @RequestParam(required = false) Long serviceId,
+                       @ApiParam(value = "用途类型") @RequestParam(required = false) DeviceUsageTypeEnum usageType,
+                       @ApiParam(value = "项目单号") @RequestParam(required = false) String crmNo,
+                       @ApiParam(value = "发货状态") @RequestParam(required = false) DeviceDeliveryStatusEnum status,
+                       @ApiParam(value = "发货人id") @RequestParam(required = false) Long deliverUserId,
+                       @ApiParam(value = "派单开始时间") @RequestParam(required = false) Long crmStartTime,
+                       @ApiParam(value = "派单结束时间") @RequestParam(required = false) Long crmEndTime,
+                       @ApiParam(value = "设备序列号") @RequestParam(required = false) String serialNo,
+                       @ApiParam(value = "供应商id") @RequestParam(required = false) Long supplierId,
+                       @ApiParam(value = "签收开始时间") @RequestParam(required = false) Long receiveStartTime,
+                       @ApiParam(value = "签收结束时间") @RequestParam(required = false) Long receiveEndTime,
+                       @ApiParam(value = "页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) Integer pageNumber,
+                       @ApiParam(value = "页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.PAGE_SIZE_MAX) Integer pageSize) {
+        return ResultUtil.ok(tbDeviceDeliveryService.list(new Page<>(pageNumber, pageSize), serviceId, usageType, crmNo, status, deliverUserId, crmStartTime, crmEndTime, serialNo, supplierId, receiveStartTime, receiveEndTime));
+    }
+
+    @ApiOperation(value = "设备发货保存接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = Object.class)})
-    @OperationLog(logType = LogTypeEnum.EDIT)
+    @OperationLog(logType = LogTypeEnum.UPDATE)
     @Transactional
     public Result save(@Valid @ApiParam(value = "设备发货修改信息", required = true) @RequestBody TBDeviceDelivery tbDeviceDelivery, BindingResult bindingResult) throws Exception {
         if (bindingResult.hasErrors()) {
             return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
         }
-        return ResultUtil.ok();
+        return ResultUtil.ok(tbDeviceDeliveryService.saveOrUpdate(tbDeviceDelivery));
+    }
+
+    @ApiOperation(value = "设备发货修改接口")
+    @RequestMapping(value = "/edit", method = RequestMethod.POST)
+    @ApiResponses({@ApiResponse(code = 200, message = "返回信息", response = TBDeviceDelivery.class)})
+    @OperationLog(logType = LogTypeEnum.EDIT)
+    @Transactional
+    public Result edit(@ApiParam(value = "设备发货id", required = true) @RequestParam Long id) throws Exception {
+        TBDeviceDelivery tbDeviceDelivery = tbDeviceDeliveryService.getById(id);
+        Optional.ofNullable(tbDeviceDelivery).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("未找到设备发货信息"));
+        return ResultUtil.ok(tbDeviceDelivery);
     }
 
     @ApiOperation(value = "设备发货状态修改接口")

+ 18 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/result/TBDeviceDeliveryResult.java

@@ -0,0 +1,18 @@
+package com.qmth.sop.business.bean.result;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.qmth.sop.business.entity.TBDeviceDelivery;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 设备发货管理result
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2023/11/30
+ */
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class TBDeviceDeliveryResult extends TBDeviceDelivery implements Serializable {
+
+}

+ 5 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBDeviceDelivery.java

@@ -9,6 +9,7 @@ import com.qmth.sop.common.enums.InOutTypeEnum;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 
+import javax.validation.constraints.NotNull;
 import java.io.Serializable;
 
 /**
@@ -48,15 +49,19 @@ public class TBDeviceDelivery extends BaseEntity implements Serializable {
     private Integer num;
 
     @ApiModelProperty(value = "邮寄地址")
+    @NotNull(message = "邮寄地址地址不能为空")
     private String mailingAddress;
 
     @ApiModelProperty(value = "收件人")
+    @NotNull(message = "收件人不能为空")
     private String consignee;
 
     @ApiModelProperty(value = "收件人联系电话")
+    @NotNull(message = "收件人联系电话不能为空")
     private String consigneePhone;
 
     @ApiModelProperty(value = "快递单号")
+    @NotNull(message = "快递单号不能为空")
     private String expressNo;
 
     @ApiModelProperty(value = "快递单拍照")

+ 24 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBDeviceDeliveryMapper.java

@@ -1,7 +1,12 @@
 package com.qmth.sop.business.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.Map;
 
 /**
  * <p>
@@ -13,4 +18,23 @@ import com.qmth.sop.business.entity.TBDeviceDelivery;
  */
 public interface TBDeviceDeliveryMapper extends BaseMapper<TBDeviceDelivery> {
 
+    /**
+     * 设备发货管理列表
+     *
+     * @param iPage
+     * @param serviceId
+     * @param usageType
+     * @param crmNo
+     * @param status
+     * @param deliverUserId
+     * @param crmStartTime
+     * @param crmEndTime
+     * @param serialNo
+     * @param supplierId
+     * @param receiveStartTime
+     * @param receiveEndTime
+     * @param createId
+     * @return
+     */
+    IPage<TBDeviceDeliveryResult> list(IPage<Map> iPage, @Param("serviceId") Long serviceId, @Param("usageType") String usageType, @Param("crmNo") String crmNo, @Param("status") String status, @Param("deliverUserId") Long deliverUserId, @Param("crmStartTime") Long crmStartTime, @Param("crmEndTime") Long crmEndTime, @Param("serialNo") String serialNo, @Param("supplierId") Long supplierId, @Param("receiveStartTime") Long receiveStartTime, @Param("receiveEndTime") Long receiveEndTime, @Param("createId") Long createId);
 }

+ 24 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBDeviceDeliveryService.java

@@ -1,7 +1,13 @@
 package com.qmth.sop.business.service;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
+import com.qmth.sop.common.enums.DeviceDeliveryStatusEnum;
+import com.qmth.sop.common.enums.DeviceUsageTypeEnum;
+
+import java.util.Map;
 
 /**
  * <p>
@@ -13,4 +19,22 @@ import com.qmth.sop.business.entity.TBDeviceDelivery;
  */
 public interface TBDeviceDeliveryService extends IService<TBDeviceDelivery> {
 
+    /**
+     * 设备发货管理列表
+     *
+     * @param iPage
+     * @param serviceId
+     * @param usageType
+     * @param crmNo
+     * @param status
+     * @param deliverUserId
+     * @param crmStartTime
+     * @param crmEndTime
+     * @param serialNo
+     * @param supplierId
+     * @param receiveStartTime
+     * @param receiveEndTime
+     * @return
+     */
+    IPage<TBDeviceDeliveryResult> list(IPage<Map> iPage, Long serviceId, DeviceUsageTypeEnum usageType, String crmNo, DeviceDeliveryStatusEnum status, Long deliverUserId, Long crmStartTime, Long crmEndTime, String serialNo, Long supplierId, Long receiveStartTime, Long receiveEndTime);
 }

+ 31 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java

@@ -1,11 +1,20 @@
 package com.qmth.sop.business.service.impl;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
+import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
 import com.qmth.sop.business.mapper.TBDeviceDeliveryMapper;
 import com.qmth.sop.business.service.TBDeviceDeliveryService;
+import com.qmth.sop.common.enums.DeviceDeliveryStatusEnum;
+import com.qmth.sop.common.enums.DeviceUsageTypeEnum;
+import com.qmth.sop.common.util.ServletUtil;
 import org.springframework.stereotype.Service;
 
+import java.util.Map;
+import java.util.Objects;
+
 /**
  * <p>
  * 设备发货表 服务实现类
@@ -17,4 +26,26 @@ import org.springframework.stereotype.Service;
 @Service
 public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMapper, TBDeviceDelivery> implements TBDeviceDeliveryService {
 
+    /**
+     * 设备发货管理列表
+     *
+     * @param iPage
+     * @param serviceId
+     * @param usageType
+     * @param crmNo
+     * @param status
+     * @param deliverUserId
+     * @param crmStartTime
+     * @param crmEndTime
+     * @param serialNo
+     * @param supplierId
+     * @param receiveStartTime
+     * @param receiveEndTime
+     * @return
+     */
+    @Override
+    public IPage<TBDeviceDeliveryResult> list(IPage<Map> iPage, Long serviceId, DeviceUsageTypeEnum usageType, String crmNo, DeviceDeliveryStatusEnum status, Long deliverUserId, Long crmStartTime, Long crmEndTime, String serialNo, Long supplierId, Long receiveStartTime, Long receiveEndTime) {
+        SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+        return this.baseMapper.list(iPage, serviceId, Objects.nonNull(usageType) ? usageType.name() : null, crmNo, Objects.nonNull(status) ? status.name() : null, deliverUserId, crmStartTime, crmEndTime, serialNo, supplierId, receiveStartTime, receiveEndTime, sysUser.getId());
+    }
 }

+ 9 - 2
sop-business/src/main/resources/db/log/wangliang_update_log.sql

@@ -2211,7 +2211,7 @@ CREATE TABLE `t_b_device_delivery` (
                                        `deliver_user_id` bigint DEFAULT NULL COMMENT '发货人id',
                                        `receive_time` bigint DEFAULT NULL COMMENT '签收时间',
                                        `receive_user_id` bigint DEFAULT NULL COMMENT '签收人id',
-                                       `enable` tinyint DEFAULT NULL COMMENT '是否启用,0:停用,1:启用',
+                                       `enable` tinyint DEFAULT '1' NULL COMMENT '是否启用,0:停用,1:启用',
                                        `create_id` bigint DEFAULT NULL COMMENT '创建人id',
                                        `create_time` bigint DEFAULT NULL COMMENT '创建时间',
                                        `update_id` bigint DEFAULT NULL COMMENT '更新人id',
@@ -2304,4 +2304,11 @@ INSERT INTO sys_privilege
 VALUES(3067, '设备发货状态批量修改接口', '/api/admin/device/delivery/status/batch/update', 'URL', 36, 3, 'AUTH', NULL, 1, 1, 0);
 
 ALTER TABLE sys_device DROP KEY sys_device_un_device_code;
-ALTER TABLE sys_device ADD CONSTRAINT sys_device_un_serial_no UNIQUE KEY (serial_no);
+ALTER TABLE sys_device ADD CONSTRAINT sys_device_un_serial_no UNIQUE KEY (serial_no);
+
+--2023.11.30update
+UPDATE sys_privilege
+SET name='设备发货保存接口', url='/api/admin/device/delivery/save', `type`='URL', parent_id=36, `sequence`=1, property='AUTH', related=NULL, enable=1, default_auth=1, front_display=0
+WHERE id=3065;
+
+ALTER TABLE t_b_device_delivery MODIFY COLUMN enable tinyint DEFAULT 1 NULL COMMENT '是否启用,0:停用,1:启用';

+ 68 - 0
sop-business/src/main/resources/mapper/TBDeviceDeliveryMapper.xml

@@ -2,4 +2,72 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.sop.business.mapper.TBDeviceDeliveryMapper">
 
+    <select id="list" resultType="com.qmth.sop.business.bean.result.TBDeviceDeliveryResult">
+        select
+            tbdd.id,
+            tbs.name as serviceName,
+            tbdd.crm_no as crmNo,
+            tbdd.usage_type as usageType,
+            tbdd.delivery_type as deliveryType,
+            ss.name as supplierName,
+            sd.device_code as deviceCode,
+            sd.serial_no as serialNo,
+            sdb.brand,
+            sdm.model,
+            tbdd.mailing_address as mailingAddress,
+            tbdd.consignee,
+            tbdd.consignee_phone as consigneePhone,
+            tbdd.express_no as expressNo,
+            tbdd.express_photo_path as expressPhotoPath,
+            tbdd.status,
+            tbdd.deliver_time as deliverTime,
+            su.real_name as realName,
+            tbdd.receive_time
+        from
+            t_b_device_delivery tbdd
+                left join t_b_service tbs on tbdd.service_id = tbs.id
+                left join t_b_crm tbc on tbc.crm_no = tbdd.crm_no
+                left join sys_supplier ss on ss.id = tbdd.supplier_id
+                left join sys_device sd on sd.serial_no = tbdd.serial_no
+                left join sys_device_brand sdb on sdb.brand = sd.brand
+                left join sys_device_model sdm on sdm.brand_id = sdb.id
+                left join sys_user su on su.id = tbdd.deliver_user_id
+        <where> 1 = 1
+            <if test="serviceId != null and serviceId != ''">
+                tbdd.service_id = #{serviceId}
+            </if>
+            <if test="usageType != null and usageType != ''">
+                tbdd.usage_type = #{usageType}
+            </if>
+            <if test="crmNo != null and crmNo != ''">
+                tbdd.crm_no = #{crmNo}
+            </if>
+            <if test="status != null and status != ''">
+                tbdd.status = #{status}
+            </if>
+            <if test="deliverUserId != null and deliverUserId != ''">
+                tbdd.deliver_user_id = #{deliverUserId}
+            </if>
+            <if test="crmStartTime != null and crmStartTime != ''">
+                tbc.begin_time <![CDATA[ >= ]]> #{crmStartTime}
+            </if>
+            <if test="crmEndTime != null and crmEndTime != ''">
+                tbc.begin_time <![CDATA[ <= ]]> #{crmEndTime}
+            </if>
+            <if test="serialNo != null and serialNo != ''">
+                tbdd.serial_no = #{serialNo}
+            </if>
+            <if test="supplierId != null and supplierId != ''">
+                tbdd.supplier_id = #{supplierId}
+            </if>
+            <if test="receiveStartTime != null and receiveStartTime != ''">
+                tbc.receive_time <![CDATA[ >= ]]> #{receiveStartTime}
+            </if>
+            <if test="receiveEndTime != null and receiveEndTime != ''">
+                tbc.receive_time <![CDATA[ <= ]]> #{receiveEndTime}
+            </if>
+            and tbdd.enable = 1
+            and tbdd.create_id = #{createId}
+        </where>
+    </select>
 </mapper>