Эх сурвалжийг харах

Merge remote-tracking branch 'origin/dev_v1.0.1' into dev_v1.0.1

# Conflicts:
#	sop-api/src/main/java/com/qmth/sop/server/api/TBDeviceDeliveryController.java
#	sop-business/src/main/java/com/qmth/sop/business/service/TBDeviceDeliveryService.java
#	sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java
wangliang 1 жил өмнө
parent
commit
5c1c130f87
15 өөрчлөгдсөн 637 нэмэгдсэн , 175 устгасан
  1. 150 0
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/DeviceDeliveryImportDto.java
  2. 54 0
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/DeviceInfoDto.java
  3. 73 0
      sop-business/src/main/java/com/qmth/sop/business/bean/params/DeviceDeliveryParam.java
  4. 12 0
      sop-business/src/main/java/com/qmth/sop/business/entity/SysUser.java
  5. 22 17
      sop-business/src/main/java/com/qmth/sop/business/service/SysDeviceBrandService.java
  6. 24 17
      sop-business/src/main/java/com/qmth/sop/business/service/SysDeviceModelService.java
  7. 13 20
      sop-business/src/main/java/com/qmth/sop/business/service/TBDeviceDeliveryService.java
  8. 63 45
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceBrandServiceImpl.java
  9. 52 45
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceModelServiceImpl.java
  10. 151 28
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java
  11. 1 0
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesServiceImpl.java
  12. 1 1
      sop-business/src/main/java/com/qmth/sop/business/sync/FxxkApiUtils.java
  13. 9 0
      sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncDeviceDeliveryImportService.java
  14. 9 1
      sop-business/src/main/resources/db/log/caozixuan_update_log.sql
  15. 3 1
      sop-common/src/main/java/com/qmth/sop/common/enums/FieldUniqueEnum.java

+ 150 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/DeviceDeliveryImportDto.java

@@ -0,0 +1,150 @@
+package com.qmth.sop.business.bean.dto;
+
+import com.alibaba.excel.annotation.ExcelProperty;
+import com.alibaba.excel.annotation.write.style.ColumnWidth;
+import com.alibaba.excel.annotation.write.style.HeadFontStyle;
+import com.alibaba.excel.annotation.write.style.HeadStyle;
+import com.qmth.sop.business.util.excel.BasicExcelRow;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @Description: 设备发货导入模板
+ * @Author: CaoZixuan
+ * @Date: 2023-11-29
+ */
+@ColumnWidth(value = 30)
+@HeadStyle(fillForegroundColor = 11)
+@HeadFontStyle(color = 1)
+public class DeviceDeliveryImportDto extends BasicExcelRow implements Serializable {
+    @ExcelProperty(value = "项目单号/项目编号")
+    private String crmNo;
+
+    @ExcelProperty(value = "供应商*")
+    @NotNull(message = "供应商不能为空")
+    @NotBlank(message = "供应商不能为空")
+    private String supplierName;
+
+    @ExcelProperty(value = "设备编号*")
+    @NotNull(message = "设备编号不能为空")
+    @NotBlank(message = "设备编号不能为空")
+    private String deviceNo;
+
+    @ExcelProperty(value = "序列号*")
+    @NotNull(message = "序列号不能为空")
+    @NotBlank(message = "序列号不能为空")
+    private String serialNo;
+
+    @ExcelProperty(value = "品牌*")
+    @NotNull(message = "品牌不能为空")
+    @NotBlank(message = "品牌不能为空")
+    private String brand;
+
+    @ExcelProperty(value = "型号*")
+    @NotNull(message = "型号不能为空")
+    @NotBlank(message = "型号不能为空")
+    private String model;
+
+    @ExcelProperty(value = "邮寄地址*")
+    @NotNull(message = "邮寄地址不能为空")
+    @NotBlank(message = "邮寄地址不能为空")
+    private String mailingAddress;
+
+    @ExcelProperty(value = "收件人*")
+    @NotNull(message = "收件人不能为空")
+    @NotBlank(message = "收件人不能为空")
+    private String consignee;
+
+    @ExcelProperty(value = "收件人联系电话*")
+    @NotNull(message = "收件人联系电话不能为空")
+    @NotBlank(message = "收件人联系电话不能为空")
+    private String consigneePhone;
+
+    @ExcelProperty(value = "快递单号*")
+    @NotNull(message = "快递单号不能为空")
+    @NotBlank(message = "快递单号不能为空")
+    private String expressNo;
+
+    public String getCrmNo() {
+        return crmNo;
+    }
+
+    public void setCrmNo(String crmNo) {
+        this.crmNo = crmNo;
+    }
+
+    public String getSupplierName() {
+        return supplierName;
+    }
+
+    public void setSupplierName(String supplierName) {
+        this.supplierName = supplierName;
+    }
+
+    public String getDeviceNo() {
+        return deviceNo;
+    }
+
+    public void setDeviceNo(String deviceNo) {
+        this.deviceNo = deviceNo;
+    }
+
+    public String getSerialNo() {
+        return serialNo;
+    }
+
+    public void setSerialNo(String serialNo) {
+        this.serialNo = serialNo;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+
+    public String getMailingAddress() {
+        return mailingAddress;
+    }
+
+    public void setMailingAddress(String mailingAddress) {
+        this.mailingAddress = mailingAddress;
+    }
+
+    public String getConsignee() {
+        return consignee;
+    }
+
+    public void setConsignee(String consignee) {
+        this.consignee = consignee;
+    }
+
+    public String getConsigneePhone() {
+        return consigneePhone;
+    }
+
+    public void setConsigneePhone(String consigneePhone) {
+        this.consigneePhone = consigneePhone;
+    }
+
+    public String getExpressNo() {
+        return expressNo;
+    }
+
+    public void setExpressNo(String expressNo) {
+        this.expressNo = expressNo;
+    }
+}
+

+ 54 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/dto/DeviceInfoDto.java

@@ -0,0 +1,54 @@
+package com.qmth.sop.business.bean.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+
+/**
+ * @Description: 设备信息dto
+ * @Author: CaoZixuan
+ * @Date: 2023-11-29
+ */
+public class DeviceInfoDto {
+    @ApiModelProperty("设备编号")
+    private String deviceNo;
+
+    @ApiModelProperty("设备序列号")
+    private String serialNo;
+
+    @ApiModelProperty("品牌")
+    private String brand;
+
+    @ApiModelProperty("型号")
+    private String model;
+
+    public String getDeviceNo() {
+        return deviceNo;
+    }
+
+    public void setDeviceNo(String deviceNo) {
+        this.deviceNo = deviceNo;
+    }
+
+    public String getSerialNo() {
+        return serialNo;
+    }
+
+    public void setSerialNo(String serialNo) {
+        this.serialNo = serialNo;
+    }
+
+    public String getBrand() {
+        return brand;
+    }
+
+    public void setBrand(String brand) {
+        this.brand = brand;
+    }
+
+    public String getModel() {
+        return model;
+    }
+
+    public void setModel(String model) {
+        this.model = model;
+    }
+}

+ 73 - 0
sop-business/src/main/java/com/qmth/sop/business/bean/params/DeviceDeliveryParam.java

@@ -0,0 +1,73 @@
+package com.qmth.sop.business.bean.params;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+import org.hibernate.validator.constraints.Range;
+
+import javax.validation.constraints.NotNull;
+
+/**
+ * @Description: 发货设备更新参数
+ * @Author: CaoZixuan
+ * @Date: 2023-11-30
+ */
+public class DeviceDeliveryParam {
+    @ApiModelProperty("id")
+    @NotNull(message = "缺少id")
+    @Range(min = 1L, message = "缺少id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long id;
+
+    @ApiModelProperty("邮寄地址")
+    private String mailingAddress;
+
+    @ApiModelProperty("收件人")
+    private String consignee;
+
+    @ApiModelProperty("收件人联系电话")
+    private String consigneePhone;
+
+    @ApiModelProperty("快递单号")
+    private String expressNo;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getMailingAddress() {
+        return mailingAddress;
+    }
+
+    public void setMailingAddress(String mailingAddress) {
+        this.mailingAddress = mailingAddress;
+    }
+
+    public String getConsignee() {
+        return consignee;
+    }
+
+    public void setConsignee(String consignee) {
+        this.consignee = consignee;
+    }
+
+    public String getConsigneePhone() {
+        return consigneePhone;
+    }
+
+    public void setConsigneePhone(String consigneePhone) {
+        this.consigneePhone = consigneePhone;
+    }
+
+    public String getExpressNo() {
+        return expressNo;
+    }
+
+    public void setExpressNo(String expressNo) {
+        this.expressNo = expressNo;
+    }
+}

+ 12 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/SysUser.java

@@ -76,6 +76,10 @@ public class SysUser extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "来源,SYSTEM:系统自带,ARCHIVES:档案")
     @ApiModelProperty(value = "来源,SYSTEM:系统自带,ARCHIVES:档案")
     private UserSourceEnum source;
     private UserSourceEnum source;
 
 
+    @ApiModelProperty(value = "供应商id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long supplierId;
+
     @ApiModelProperty("软通智服用户同步状态")
     @ApiModelProperty("软通智服用户同步状态")
     private RtzfSyncStatusEnum rtzfSyncStatus;
     private RtzfSyncStatusEnum rtzfSyncStatus;
 
 
@@ -221,4 +225,12 @@ public class SysUser extends BaseEntity implements Serializable {
     public void setRtzfSyncStatus(RtzfSyncStatusEnum rtzfSyncStatus) {
     public void setRtzfSyncStatus(RtzfSyncStatusEnum rtzfSyncStatus) {
         this.rtzfSyncStatus = rtzfSyncStatus;
         this.rtzfSyncStatus = rtzfSyncStatus;
     }
     }
+
+    public Long getSupplierId() {
+        return supplierId;
+    }
+
+    public void setSupplierId(Long supplierId) {
+        this.supplierId = supplierId;
+    }
 }
 }

+ 22 - 17
sop-business/src/main/java/com/qmth/sop/business/service/SysDeviceBrandService.java

@@ -14,30 +14,35 @@ import java.util.Map;
  * @email: shudonghui@qmth.com.cn
  * @email: shudonghui@qmth.com.cn
  * @Company: www.qmth.com.cn
  * @Company: www.qmth.com.cn
  */
  */
-public interface SysDeviceBrandService extends IService<SysDeviceBrand>{
+public interface SysDeviceBrandService extends IService<SysDeviceBrand> {
 
 
     /**
     /**
-    * 查询列表
-    *
-    * @param iPage
-    * @return
-    */
-    IPage<SysDeviceBrand> query(IPage<Map> iPage,String query);
+     * 查询列表
+     *
+     * @param iPage iPage
+     * @return 结果
+     */
+    IPage<SysDeviceBrand> query(IPage<Map> iPage, String query);
 
 
     /**
     /**
-    * 新增修改设备品牌表
-    *
-    * @param sysDeviceBrand
-    */
+     * 新增修改设备品牌表
+     *
+     * @param sysDeviceBrand sysDeviceBrand
+     */
     Boolean saveSysDeviceBrand(SysDeviceBrand sysDeviceBrand);
     Boolean saveSysDeviceBrand(SysDeviceBrand sysDeviceBrand);
 
 
+    /**
+     * 根据设备品牌查询或新增
+     *
+     * @param brand 设备品牌
+     * @return 设备品牌id
+     */
+    SysDeviceBrand findOrAddDeviceBrand(String brand);
 
 
     /**
     /**
-    * 删除设备品牌表
-    *
-    * @param id
-    */
+     * 删除设备品牌表
+     *
+     * @param id id
+     */
     Boolean delete(Long id);
     Boolean delete(Long id);
-
-
 }
 }

+ 24 - 17
sop-business/src/main/java/com/qmth/sop/business/service/SysDeviceModelService.java

@@ -14,30 +14,37 @@ import java.util.Map;
  * @email: shudonghui@qmth.com.cn
  * @email: shudonghui@qmth.com.cn
  * @Company: www.qmth.com.cn
  * @Company: www.qmth.com.cn
  */
  */
-public interface SysDeviceModelService extends IService<SysDeviceModel>{
+public interface SysDeviceModelService extends IService<SysDeviceModel> {
 
 
     /**
     /**
-    * 查询列表
-    *
-    * @param iPage
-    * @return
-    */
-    IPage<SysDeviceModel> query(IPage<Map> iPage,String query);
+     * 查询列表
+     *
+     * @param iPage iPage
+     * @return 结果
+     */
+    IPage<SysDeviceModel> query(IPage<Map> iPage, String query);
 
 
     /**
     /**
-    * 新增修改设备品牌型号表
-    *
-    * @param sysDeviceModel
-    */
+     * 新增修改设备品牌型号表
+     *
+     * @param sysDeviceModel sysDeviceModel
+     */
     Boolean saveSysDeviceModel(SysDeviceModel sysDeviceModel);
     Boolean saveSysDeviceModel(SysDeviceModel sysDeviceModel);
 
 
-
     /**
     /**
-    * 删除设备品牌型号表
-    *
-    * @param id
-    */
-    Boolean delete(Long id);
+     * 查询或新增设备幸好偶
+     *
+     * @param brand 品牌
+     * @param model 型号
+     * @return 型号id
+     */
+    SysDeviceModel findOrAddDeviceModel(String brand, String model);
 
 
 
 
+    /**
+     * 删除设备品牌型号表
+     *
+     * @param id id
+     */
+    Boolean delete(Long id);
 }
 }

+ 13 - 20
sop-business/src/main/java/com/qmth/sop/business/service/TBDeviceDeliveryService.java

@@ -1,13 +1,11 @@
 package com.qmth.sop.business.service;
 package com.qmth.sop.business.service;
 
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.qmth.sop.business.bean.result.TBDeviceDeliveryResult;
+import com.qmth.sop.business.bean.params.DeviceDeliveryParam;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
-import com.qmth.sop.common.enums.DeviceDeliveryStatusEnum;
-import com.qmth.sop.common.enums.DeviceUsageTypeEnum;
+import org.springframework.web.multipart.MultipartFile;
 
 
-import java.util.Map;
+import java.io.IOException;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -18,23 +16,18 @@ import java.util.Map;
  * @since 2023-11-28
  * @since 2023-11-28
  */
  */
 public interface TBDeviceDeliveryService extends IService<TBDeviceDelivery> {
 public interface TBDeviceDeliveryService extends IService<TBDeviceDelivery> {
+    /**
+     * 设备发货导入
+     *
+     * @param file excel文件
+     * @throws IOException 异常
+     */
+    void deviceDeliveryImport(MultipartFile file) throws IOException;
 
 
     /**
     /**
-     * 设备发货管理列表
+     * 设备发货修改
      *
      *
-     * @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
+     * @param deviceDeliveryParam 设备发货修改参数
      */
      */
-    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);
+    void editDeviceDelivery(DeviceDeliveryParam deviceDeliveryParam);
 }
 }

+ 63 - 45
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceBrandServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.sop.business.service.impl;
 package com.qmth.sop.business.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.boot.api.exception.ApiException;
@@ -7,6 +8,7 @@ import com.qmth.sop.business.entity.SysDeviceBrand;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.mapper.SysDeviceBrandMapper;
 import com.qmth.sop.business.mapper.SysDeviceBrandMapper;
 import com.qmth.sop.business.service.SysDeviceBrandService;
 import com.qmth.sop.business.service.SysDeviceBrandService;
+import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.util.ResultUtil;
 import com.qmth.sop.common.util.ResultUtil;
@@ -28,59 +30,75 @@ import java.util.Objects;
  * @Company: www.qmth.com.cn
  * @Company: www.qmth.com.cn
  */
  */
 @Service
 @Service
-public class SysDeviceBrandServiceImpl extends ServiceImpl<SysDeviceBrandMapper, SysDeviceBrand> implements SysDeviceBrandService{
+public class SysDeviceBrandServiceImpl extends ServiceImpl<SysDeviceBrandMapper, SysDeviceBrand> implements SysDeviceBrandService {
 
 
 
 
-		/**
-		* 查询列表
-		*
-		* @param iPage
-		* @return
-		*/
-		@Override
-		public IPage<SysDeviceBrand> query(IPage<Map> iPage,String query) {
-				return this.baseMapper.query(iPage,query);
-		}
-		/**
-		* 新增修改设备品牌表
-		*
-		* @param sysDeviceBrand
-		*/
-		@Override
-		@Transactional
-		public Boolean saveSysDeviceBrand(SysDeviceBrand sysDeviceBrand) {
-			try {
-				SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-				if (Objects.isNull(sysDeviceBrand.getId())) {// 新增
-					sysDeviceBrand.insertInfo(sysUser.getId());
-				} else { // 修改
-					sysDeviceBrand.updateInfo(sysUser.getId());
-				}
-				return saveOrUpdate(sysDeviceBrand);
-			} catch (Exception e) {
-				if (e instanceof DuplicateKeyException) {
+	/**
+	 * 查询列表
+	 *
+	 * @param iPage
+	 * @return
+	 */
+	@Override
+	public IPage<SysDeviceBrand> query(IPage<Map> iPage, String query) {
+		return this.baseMapper.query(iPage, query);
+	}
+
+	/**
+	 * 新增修改设备品牌表
+	 *
+	 * @param sysDeviceBrand
+	 */
+	@Override
+	@Transactional
+	public Boolean saveSysDeviceBrand(SysDeviceBrand sysDeviceBrand) {
+		try {
+			SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+			if (Objects.isNull(sysDeviceBrand.getId())) {// 新增
+				sysDeviceBrand.insertInfo(sysUser.getId());
+			} else { // 修改
+				sysDeviceBrand.updateInfo(sysUser.getId());
+			}
+			return saveOrUpdate(sysDeviceBrand);
+		} catch (Exception e) {
+			if (e instanceof DuplicateKeyException) {
 				String errorColumn = e.getCause().toString();
 				String errorColumn = e.getCause().toString();
-				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
+				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3).replaceAll("'", "");
 				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
 				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
-				} else if (e instanceof ApiException) {
-                    ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
-				} else {
+			} else if (e instanceof ApiException) {
+				ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
+			} else {
 				ResultUtil.error(e.getMessage());
 				ResultUtil.error(e.getMessage());
-				}
 			}
 			}
-			return null;
-
 		}
 		}
+		return null;
+
+	}
 
 
-		/**
-		* 删除设备品牌表
-		*
-		* @param id
-		*/
-		@Override
-		@Transactional
-		public Boolean delete(Long id) {
-			return this.removeById(id);
+	@Transactional
+	@Override
+	public SysDeviceBrand findOrAddDeviceBrand(String brand) {
+		SysDeviceBrand sysDeviceBrand = this.getOne(new QueryWrapper<SysDeviceBrand>()
+				.lambda()
+				.eq(SysDeviceBrand::getBrand, brand)
+				.last(SystemConstant.LIMIT1));
+		if (Objects.isNull(sysDeviceBrand)) {
+			// 新增
+			sysDeviceBrand = new SysDeviceBrand();
+			sysDeviceBrand.setBrand(brand);
+			this.saveSysDeviceBrand(sysDeviceBrand);
 		}
 		}
+		return sysDeviceBrand;
+	}
 
 
+	/**
+	 * 删除设备品牌表
+	 *
+	 * @param id
+	 */
+	@Override
+	@Transactional
+	public Boolean delete(Long id) {
+		return this.removeById(id);
+	}
 }
 }

+ 52 - 45
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysDeviceModelServiceImpl.java

@@ -1,12 +1,15 @@
 package com.qmth.sop.business.service.impl;
 package com.qmth.sop.business.service.impl;
 
 
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.boot.api.exception.ApiException;
 import com.qmth.sop.business.entity.SysDeviceModel;
 import com.qmth.sop.business.entity.SysDeviceModel;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.mapper.SysDeviceModelMapper;
 import com.qmth.sop.business.mapper.SysDeviceModelMapper;
+import com.qmth.sop.business.service.SysDeviceBrandService;
 import com.qmth.sop.business.service.SysDeviceModelService;
 import com.qmth.sop.business.service.SysDeviceModelService;
+import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.ExceptionResultEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.enums.FieldUniqueEnum;
 import com.qmth.sop.common.util.ResultUtil;
 import com.qmth.sop.common.util.ResultUtil;
@@ -15,6 +18,7 @@ import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
+import javax.annotation.Resource;
 import java.util.Map;
 import java.util.Map;
 import java.util.Objects;
 import java.util.Objects;
 
 
@@ -28,59 +32,62 @@ import java.util.Objects;
  * @Company: www.qmth.com.cn
  * @Company: www.qmth.com.cn
  */
  */
 @Service
 @Service
-public class SysDeviceModelServiceImpl extends ServiceImpl<SysDeviceModelMapper, SysDeviceModel> implements SysDeviceModelService{
+public class SysDeviceModelServiceImpl extends ServiceImpl<SysDeviceModelMapper, SysDeviceModel> implements SysDeviceModelService {
+	@Resource
+	private SysDeviceBrandService sysDeviceBrandService;
 
 
+	@Override
+	public IPage<SysDeviceModel> query(IPage<Map> iPage, String query) {
+		return this.baseMapper.query(iPage, query);
+	}
 
 
-		/**
-		* 查询列表
-		*
-		* @param iPage
-		* @return
-		*/
-		@Override
-		public IPage<SysDeviceModel> query(IPage<Map> iPage,String query) {
-				return this.baseMapper.query(iPage,query);
-		}
-		/**
-		* 新增修改设备品牌型号表
-		*
-		* @param sysDeviceModel
-		*/
-		@Override
-		@Transactional
-		public Boolean saveSysDeviceModel(SysDeviceModel sysDeviceModel) {
-			try {
-				SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-				if (Objects.isNull(sysDeviceModel.getId())) {// 新增
-					sysDeviceModel.insertInfo(sysUser.getId());
-				} else { // 修改
-					sysDeviceModel.updateInfo(sysUser.getId());
-				}
-				return saveOrUpdate(sysDeviceModel);
-			} catch (Exception e) {
-				if (e instanceof DuplicateKeyException) {
+	@Override
+	@Transactional
+	public Boolean saveSysDeviceModel(SysDeviceModel sysDeviceModel) {
+		try {
+			SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
+			if (Objects.isNull(sysDeviceModel.getId())) {// 新增
+				sysDeviceModel.insertInfo(sysUser.getId());
+			} else { // 修改
+				sysDeviceModel.updateInfo(sysUser.getId());
+			}
+			return saveOrUpdate(sysDeviceModel);
+		} catch (Exception e) {
+			if (e instanceof DuplicateKeyException) {
 				String errorColumn = e.getCause().toString();
 				String errorColumn = e.getCause().toString();
-				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3, errorColumn.length()).replaceAll("'", "");
+				String columnStr = errorColumn.substring(errorColumn.lastIndexOf("key") + 3).replaceAll("'", "");
 				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
 				throw ExceptionResultEnum.SQL_ERROR.exception("[" + FieldUniqueEnum.convertToTitle(columnStr) + "]数据不允许重复插入");
-				} else if (e instanceof ApiException) {
-                    ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
-				} else {
+			} else if (e instanceof ApiException) {
+				ResultUtil.error((ApiException) e, ((ApiException) e).getCode(), e.getMessage());
+			} else {
 				ResultUtil.error(e.getMessage());
 				ResultUtil.error(e.getMessage());
-				}
 			}
 			}
-			return null;
-
 		}
 		}
+		return null;
+
+	}
 
 
-		/**
-		* 删除设备品牌型号表
-		*
-		* @param id
-		*/
-		@Override
-		@Transactional
-		public Boolean delete(Long id) {
-			return this.removeById(id);
+	@Transactional
+	@Override
+	public SysDeviceModel findOrAddDeviceModel(String brand, String model) {
+		Long brandId = sysDeviceBrandService.findOrAddDeviceBrand(brand).getId();
+		SysDeviceModel sysDeviceModel = this.getOne(new QueryWrapper<SysDeviceModel>()
+				.lambda()
+				.eq(SysDeviceModel::getBrandId, brandId)
+				.eq(SysDeviceModel::getModel, model)
+				.last(SystemConstant.LIMIT1));
+		if (Objects.isNull(sysDeviceModel)) {
+			sysDeviceModel = new SysDeviceModel();
+			sysDeviceModel.setBrandId(brandId);
+			sysDeviceModel.setModel(model);
+			this.saveSysDeviceModel(sysDeviceModel);
 		}
 		}
+		return sysDeviceModel;
+	}
 
 
+	@Override
+	@Transactional
+	public Boolean delete(Long id) {
+		return this.removeById(id);
+	}
 }
 }

+ 151 - 28
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java

@@ -1,19 +1,34 @@
 package com.qmth.sop.business.service.impl;
 package com.qmth.sop.business.service.impl;
 
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.alibaba.excel.EasyExcel;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 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.bean.dto.DeviceDeliveryImportDto;
+import com.qmth.sop.business.bean.dto.DeviceInfoDto;
+import com.qmth.sop.business.bean.params.DeviceDeliveryParam;
+import com.qmth.sop.business.entity.SysDevice;
+import com.qmth.sop.business.entity.SysSupplier;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
 import com.qmth.sop.business.entity.TBDeviceDelivery;
 import com.qmth.sop.business.mapper.TBDeviceDeliveryMapper;
 import com.qmth.sop.business.mapper.TBDeviceDeliveryMapper;
+import com.qmth.sop.business.service.SysDeviceModelService;
+import com.qmth.sop.business.service.SysDeviceService;
+import com.qmth.sop.business.service.SysSupplierService;
 import com.qmth.sop.business.service.TBDeviceDeliveryService;
 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 com.qmth.sop.business.util.excel.BasicExcelListener;
+import com.qmth.sop.common.contant.SystemConstant;
+import com.qmth.sop.common.enums.*;
+import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.LinkedMultiValueMap;
+import org.springframework.web.multipart.MultipartFile;
 
 
-import java.util.Map;
-import java.util.Objects;
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+import java.util.stream.Collectors;
 
 
 /**
 /**
  * <p>
  * <p>
@@ -25,27 +40,135 @@ import java.util.Objects;
  */
  */
 @Service
 @Service
 public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMapper, TBDeviceDelivery> implements TBDeviceDeliveryService {
 public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMapper, TBDeviceDelivery> implements TBDeviceDeliveryService {
+    @Resource
+    private SysDeviceService sysDeviceService;
+    @Resource
+    private SysDeviceModelService sysDeviceModelService;
+    @Resource
+    private SysSupplierService sysSupplierService;
 
 
-    /**
-     * 设备发货管理列表
-     *
-     * @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
-     */
+    @Transactional
     @Override
     @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());
+    public void deviceDeliveryImport(MultipartFile file) throws IOException {
+        InputStream inputStream = file.getInputStream();
+        LinkedMultiValueMap<String, DeviceDeliveryImportDto> deviceDeliveryImportDtoLinkedMultiValueMap = new LinkedMultiValueMap<>();
+
+        StringJoiner errorData = new StringJoiner("");
+        EasyExcel.read(inputStream, DeviceDeliveryImportDto.class, new BasicExcelListener<DeviceDeliveryImportDto>() {
+            @Override
+            public void handle(LinkedMultiValueMap<String, DeviceDeliveryImportDto> dataList, StringJoiner errorDataSj, Exception exception) {
+                deviceDeliveryImportDtoLinkedMultiValueMap.addAll(dataList);
+                errorData.add(errorDataSj.toString());
+            }
+        }).headRowNumber(2).sheet(0).doRead();
+
+        List<DeviceDeliveryImportDto> deviceDeliveryImportDtoList = deviceDeliveryImportDtoLinkedMultiValueMap.get(BasicExcelListener.SUCCESS);
+        if (CollectionUtils.isNotEmpty(deviceDeliveryImportDtoList)) {
+            List<SysSupplier> sysSupplierList = sysSupplierService.list(new QueryWrapper<SysSupplier>().lambda().eq(SysSupplier::getType, SupplierTypeEnum.DEVICE));
+            // 供应商map
+            Map<String, Long> supplierMap = sysSupplierList.stream().collect(Collectors.toMap(SysSupplier::getName, SysSupplier::getId));
+
+            // serialNo - obj
+            Map<String, DeviceInfoDto> deviceMap = new HashMap<>();
+            for (DeviceDeliveryImportDto deviceDeliveryImportDto : deviceDeliveryImportDtoList) {
+                String serialNo = deviceDeliveryImportDto.getSerialNo();
+                String deviceNo = deviceDeliveryImportDto.getDeviceNo();
+                // 品牌
+                String brand = deviceDeliveryImportDto.getBrand();
+                // 型号
+                String model = deviceDeliveryImportDto.getModel();
+                if (deviceMap.containsKey(serialNo)) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("excel中存在重复的设备序列号[%s]", serialNo));
+                } else {
+                    DeviceInfoDto deviceInfo = new DeviceInfoDto();
+                    deviceInfo.setSerialNo(serialNo);
+                    deviceInfo.setDeviceNo(deviceNo);
+                    deviceInfo.setBrand(brand);
+                    deviceInfo.setModel(model);
+                    deviceMap.put(serialNo, deviceInfo);
+                }
+                String crmNo = deviceDeliveryImportDto.getCrmNo();
+
+                String supplierName = deviceDeliveryImportDto.getSupplierName();
+                Long supplierId = supplierMap.get(supplierName);
+                if (supplierId == null || supplierId == 0) {
+                    throw ExceptionResultEnum.ERROR.exception(String.format("excel中存在系统中不存在的供应商名称[%s]", supplierName));
+                }
+
+                String mailingAddress = deviceDeliveryImportDto.getMailingAddress();
+                String consignee = deviceDeliveryImportDto.getConsignee();
+                String consigneePhone = deviceDeliveryImportDto.getConsigneePhone();
+                String expressNo = deviceDeliveryImportDto.getExpressNo();
+
+                // 查询设备表是否有该设备
+                SysDevice sysDevice = sysDeviceService.getOne(new QueryWrapper<SysDevice>()
+                        .lambda()
+                        .eq(SysDevice::getSerialNo, serialNo)
+                        .last(SystemConstant.LIMIT1));
+
+                if (Objects.isNull(sysDevice)) {
+                    // 设备表不存在该设备 -> 新增设备
+                    sysDeviceModelService.findOrAddDeviceModel(brand, model);
+
+                    SysDevice willAddSysDevice = new SysDevice();
+                    willAddSysDevice.setDeviceCode(deviceNo);
+                    willAddSysDevice.setSerialNo(serialNo);
+                    willAddSysDevice.setBrand(brand);
+                    willAddSysDevice.setModel(model);
+                    willAddSysDevice.setBuyTime(System.currentTimeMillis());
+                    willAddSysDevice.setSupplierId(supplierId);
+                    willAddSysDevice.setStatus(DeviceStatusEnum.NORMAL);
+                    willAddSysDevice.setLocation(supplierName);
+                    willAddSysDevice.setBound(InOutTypeEnum.IN);
+                    willAddSysDevice.setEnable(true);
+                    sysDeviceService.save(willAddSysDevice);
+                }
+
+                // 查询是否有发货设备
+                TBDeviceDelivery dbDeviceDelivery = this.getOne(new QueryWrapper<TBDeviceDelivery>()
+                        .lambda()
+                        .eq(TBDeviceDelivery::getSerialNo, serialNo)
+                        .eq(TBDeviceDelivery::getEffect, true)
+                        .last(SystemConstant.LIMIT1));
+
+                if (Objects.nonNull(dbDeviceDelivery)) {
+                    throw ExceptionResultEnum.EXCEPTION_ERROR.exception(String.format("excel中存在已发货的设备(序列号)[%s]", serialNo));
+                }
+
+                TBDeviceDelivery tbDeviceDelivery = new TBDeviceDelivery();
+                if (crmNo != null && crmNo.length() > 0) {
+                    tbDeviceDelivery.setCrmNo(crmNo);
+                    tbDeviceDelivery.setUsageType(DeviceUsageTypeEnum.PROJECT);
+                } else {
+                    tbDeviceDelivery.setUsageType(DeviceUsageTypeEnum.OTHER);
+                }
+                tbDeviceDelivery.setSerialNo(serialNo);
+                tbDeviceDelivery.setSupplierId(supplierId);
+                tbDeviceDelivery.setMailingAddress(mailingAddress);
+                tbDeviceDelivery.setConsignee(consignee);
+                tbDeviceDelivery.setConsigneePhone(consigneePhone);
+                tbDeviceDelivery.setExpressNo(expressNo);
+                tbDeviceDelivery.setEnable(true);
+                tbDeviceDelivery.setEffect(true);
+                this.save(tbDeviceDelivery);
+            }
+        }
+    }
+
+    @Transactional
+    @Override
+    public void editDeviceDelivery(DeviceDeliveryParam deviceDeliveryParam) {
+        Long id = deviceDeliveryParam.getId();
+        String mailingAddress = deviceDeliveryParam.getMailingAddress();
+        String consignee = deviceDeliveryParam.getConsignee();
+        String consigneePhone = deviceDeliveryParam.getConsigneePhone();
+        String expressNo = deviceDeliveryParam.getExpressNo();
+
+        this.update(new UpdateWrapper<TBDeviceDelivery>().lambda()
+                .eq(TBDeviceDelivery::getId, id)
+                .set(TBDeviceDelivery::getMailingAddress, mailingAddress)
+                .set(TBDeviceDelivery::getConsignee, consignee)
+                .set(TBDeviceDelivery::getConsigneePhone, consigneePhone)
+                .set(TBDeviceDelivery::getExpressNo, expressNo));
     }
     }
 }
 }

+ 1 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesServiceImpl.java

@@ -196,6 +196,7 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
         tbUserArchives.setEducation(education);
         tbUserArchives.setEducation(education);
         tbUserArchives.setMobileNumber(mobileNumber);
         tbUserArchives.setMobileNumber(mobileNumber);
         tbUserArchives.setEmail(email);
         tbUserArchives.setEmail(email);
+        tbUserArchives.setEnable(true);
         tbUserArchives.setBasePhotoPath(basePhotoPath);
         tbUserArchives.setBasePhotoPath(basePhotoPath);
         // 档案表编辑
         // 档案表编辑
         Long userId = null;
         Long userId = null;

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/sync/FxxkApiUtils.java

@@ -220,7 +220,7 @@ public class FxxkApiUtils {
 //            Map<String, Object> filterMap2 = new HashMap<>();
 //            Map<String, Object> filterMap2 = new HashMap<>();
 //            filterMap2.put("field_name", "name");
 //            filterMap2.put("field_name", "name");
 //            List<String> fieldValues2 = new ArrayList<>();
 //            List<String> fieldValues2 = new ArrayList<>();
-//            fieldValues2.add("Od-2023-10-2001");
+//            fieldValues2.add("Od-2023-11-0903");
 //            filterMap2.put("field_values", fieldValues2);
 //            filterMap2.put("field_values", fieldValues2);
 //            filterMap2.put("operator", "EQ");
 //            filterMap2.put("operator", "EQ");
 //            filterMapList.add(filterMap2);
 //            filterMapList.add(filterMap2);

+ 9 - 0
sop-business/src/main/java/com/qmth/sop/business/templete/execute/AsyncDeviceDeliveryImportService.java

@@ -0,0 +1,9 @@
+package com.qmth.sop.business.templete.execute;
+
+/**
+ * @Description:
+ * @Author: CaoZixuan
+ * @Date:
+ */
+public class AsyncDeviceDeliveryImportService {
+}

+ 9 - 1
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -444,4 +444,12 @@ ALTER TABLE sys_device_model
 ALTER TABLE sys_device
 ALTER TABLE sys_device
     DROP INDEX sys_device_un_device_code ,
     DROP INDEX sys_device_un_device_code ,
     ADD UNIQUE INDEX sys_device_un_serial_no (serial_no);
     ADD UNIQUE INDEX sys_device_un_serial_no (serial_no);
-;
+;
+
+-- 2023-11-30
+ALTER TABLE sys_supplier
+    ADD UNIQUE INDEX sys_supplier_un_name (name);
+;
+
+ALTER TABLE sys_user
+    ADD COLUMN supplier_id BIGINT NULL COMMENT '供应商id' AFTER source;

+ 3 - 1
sop-common/src/main/java/com/qmth/sop/common/enums/FieldUniqueEnum.java

@@ -61,7 +61,9 @@ public enum FieldUniqueEnum {
 
 
     t_b_user_archives_allocation_un("派单编号-人员档案id"),
     t_b_user_archives_allocation_un("派单编号-人员档案id"),
 
 
-    t_b_user_archives_supplier_un("人员档案id-供应商id");
+    t_b_user_archives_supplier_un("人员档案id-供应商id"),
+
+    sys_supplier_un_name("供应商名称");
 
 
     private String title;
     private String title;