提交 75a647a5 作者: “chaining”

refactor: 墙盒申请代码迁移

父级 60e528cd
......@@ -16,6 +16,10 @@
<version>2.0.0</version>
<description>wios project</description>
<properties>
<mapstruct.version>1.5.5.Final</mapstruct.version>
</properties>
<dependencies>
<dependency>
<groupId>com.boco.nbd</groupId>
......@@ -116,6 +120,43 @@
<artifactId>aspose-words</artifactId>
<version>15.8.0</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId> <!-- use mapstruct-jdk8 for Java 8 or higher -->
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-jdk8</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.dtflys.forest</groupId>
<artifactId>forest-spring-boot-starter</artifactId>
<version>1.5.27</version>
</dependency>
<dependency>
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
<version>3.1</version>
</dependency>
<dependency>
<groupId>org.deppon.com</groupId>
<artifactId>dop-sdk</artifactId>
<version>0.0.1-SNAPSHOT</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/dop-sdk-0.0.1-SNAPSHOT.jar</systemPath>
</dependency>
</dependencies>
......
package com.boco.nbd.wios.downloadfile.controller;
public interface CreateEntityGroup {
}
package com.boco.nbd.wios.downloadfile.controller;
import cn.hutool.core.util.ObjectUtil;
import com.boco.nbd.wios.manage.entity.bo.Order;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyExcelVO;
import com.boco.nbd.wios.manage.mapper.def.OrderDao;
import com.boco.nbd.wios.manage.service.impl.WallboxApplyService;
import com.boco.nbd.wios.utils.ExcelUtils;
import com.ihidea.component.api.v2.BaseResponse;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import javax.validation.ConstraintViolation;
import javax.validation.Validator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
@RestController
public class ImportControllerV2 {
@Autowired
private Validator validator;
@Autowired
private WallboxApplyService wallboxApplyService;
@Autowired
private OrderDao orderDao;
@PostMapping("/wallbox-apply/import")
@ApiOperation("导入墙盒申请")
public BaseResponse<List<WallboxApplyExcelVO>> importExcel(@RequestParam(value = "file") MultipartFile file
) throws Exception {
List<WallboxApplyExcelVO> list = ExcelUtils.read(file, WallboxApplyExcelVO.class);
for (WallboxApplyExcelVO vo : list) {
Set<ConstraintViolation<WallboxApplyExcelVO>> violations = validator.validate(vo, CreateEntityGroup
.class);
if (!violations.isEmpty()) {
String errorMessage = violations.stream()
.map(ConstraintViolation::getMessage)
.collect(Collectors.joining(";"));
vo.setErrorMessage(errorMessage);
}
if (StringUtils.isNotBlank(vo.getOrderId())){
Order order = orderDao.selectById(vo.getOrderId());
if (ObjectUtil.isNull(order)) {
vo.setErrorMessage("不存在安装订单号");
}
if (ObjectUtil.isNotNull(order)) {
vo.setWallboxModel(order.getWallboxModel());
}
if (ObjectUtil.isNotNull(wallboxApplyService.selectWallboxDetail(vo.getOrderId()))) {
vo.setErrorMessage("重复订单申请");
}
}
}
return new BaseResponse<>(list);
}
}
package com.boco.nbd.wios.manage.client;
import com.dtflys.forest.annotation.BaseRequest;
import com.dtflys.forest.annotation.Body;
import com.dtflys.forest.annotation.Post;
import java.util.Map;
/**
* <p>
* 德邦物流clinet,注意入参使用Map或者对象实体
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@BaseRequest(baseURL = "http://dpsanbox.deppon.com/sandbox-web/standard-order/", interceptor = DopInterceptor.class)
public interface DepponClient {
/**
* 新标准轨迹查询
* http://dop.deppon.com/#/wantAccess/myApiConfig
* @param {"mailNo":"7503587254"}
* @return 字符串
*/
@Post("newTraceQuery.action")
String newTraceQuery(@Body("params") Map<String,Object> params);
}
package com.boco.nbd.wios.manage.client;
import com.deppon.dop.module.sdk.shared.util.FastJsonUtil;
import com.deppon.dop.module.sdk.shared.util.SecurityUtil;
import com.dtflys.forest.exceptions.ForestRuntimeException;
import com.dtflys.forest.http.ForestRequest;
import com.dtflys.forest.http.ForestResponse;
import com.dtflys.forest.interceptor.Interceptor;
import com.dtflys.forest.reflection.ForestMethod;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
/**
* <p>
* 德邦物流请求拦截器,实现自动注入companyCode、digest、timestamp参数
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
public class DopInterceptor <T> implements Interceptor<T> {
private final String companyCode = "EWBXRCHSZX";
private final String appkey = "fe38a755ce4f7629717342e441cdedff";
/**
* 该方法在被调用时
*
* @Param request Forest请求对象
* @Param args 方法被调用时传入的参数数组
*/
@Override
public void onInvokeMethod(ForestRequest request, ForestMethod method, Object[] args) {
}
@Override
public boolean beforeExecute(ForestRequest request) {
request.addHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
// String params = request.getBody().get(0)+"";
long timestamp = System.currentTimeMillis();
String params = FastJsonUtil.toJSONString(request.getBody().getNameValueBody("params").getValue());
String digest = SecurityUtil.getStandardDigest(params + appkey + timestamp);
request.addBody("companyCode", companyCode);
request.addBody("digest", digest);
request.addBody("timestamp", timestamp);
request.addBody("params", params);
return true;
}
/**
* 该方法在请求成功响应时被调用
*/
@Override
public void onSuccess(T data, ForestRequest req, ForestResponse res) {
}
/**
* 该方法在请求发送失败时被调用
*/
@Override
public void onError(ForestRuntimeException ex, ForestRequest req, ForestResponse res) {
// 执行发送请求失败后处理的代码
int status = res.getStatusCode(); // 获取请求响应状态码
String content = res.getContent();
}
/**
* 该方法在请求发送之后被调用
*/
@Override
public void afterExecute(ForestRequest req, ForestResponse res) {
}
private String getDigest(String plainText) {
return Base64.encodeBase64String(DigestUtils.md5Hex(plainText).getBytes());
}
}
package com.boco.nbd.wios.manage.convert;
import com.boco.nbd.wios.manage.entity.bo.WallboxApply;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyInstallInfoVO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyInstallListVO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyReqVO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
/**
* <p>
* description
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Mapper
public interface WallboxApplyConvert {
WallboxApplyConvert INSTANCE = Mappers.getMapper(WallboxApplyConvert.class);
WallboxApply convert(WallboxApplyReqVO bean);
WallboxApplyInstallInfoVO convert2Info(WallboxApply bean);
WallboxApplyInstallListVO convert(WallboxApply bean);
List<WallboxApplyInstallListVO> convertList(List<WallboxApply> bean);
}
package com.boco.nbd.wios.manage.entity.bo;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 墙盒申请
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApply {
/** 自增id */
private Long id;
/** 安装订单号 */
private String orderId;
/** 安装服务商id */
private Long supplierId;
/** 申请团队名称 */
private String supplierTeam;
/** 墙盒设备型号(对应物料id) */
private String wallboxItemId;
/** 墙盒品牌 */
private String wallboxModel;
/** 物料类型 */
private String materialType;
/** 物流单号 */
private String trackingNumber;
/** 物流状态0未发货,1已发货 */
private String trackingStatus;
/** 安装状态 */
private String installStatus;
/** 区域id */
private String regionId;
/** 地址 */
private String address;
/** 车企安装单号 */
private String outOrderId;
/** 是否紧急:0:否,1:是 */
private Integer ifEmergency;
/** 是否超时:0:未超时,1:已超时 */
private Long ifTimeout;
/** 审核人员 */
private String checkAccount;
/** 申请状态:1:已申请,2:已通过,3:已驳回,4:已关闭 */
private Long checkStatus;
/** 审核备注 */
private String checkRemarks;
/** 审核时间 */
private Date checkTime;
/** 预约安装日期 */
private Date installReserveTime;
/** 安装进度 */
private Long installProcess;
/** 创建人 */
private String createAccount;
/** 创建时间 */
private Date createdTime;
/** 更新人 */
private String modifyAccount;
/** 更新时间 */
private Date modifyTime;
}
package com.boco.nbd.wios.manage.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* <p>
* 墙盒申请批量审核
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyBatchCheckDTO {
List<WallboxApplyCheckDTO> checkList;
/** 申请状态:0:已申请,1:已通过,2:已驳回,3:已关闭 */
@ApiModelProperty(value = "申请状态", notes = "1:通过,2:驳回", example = "1", required = true)
private Long checkStatus;
@ApiModelProperty(value = "审核备注",required = true)
private String checkRemarks;
}
package com.boco.nbd.wios.manage.entity.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 墙盒申请批量审核DTO
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyCheckDTO {
/** 自增id */
private Long id;
/** 安装订单号 */
@ApiModelProperty(value = "安装订单号")
private String orderId;
@ApiModelProperty(value = "安装状态")
private String installStatus;
/** 安装服务商id */
@ApiModelProperty(value = "安装服务商id")
private String supplierId;
/** 申请团队名称 */
@ApiModelProperty(value = "申请团队名称")
private String supplierTeam;
/** 墙盒品牌*/
@ApiModelProperty(value = "墙盒品牌")
private String wallboxModel;
/** 区域id */
@ApiModelProperty(value = "区域id")
private String regionId;
/** 区域id */
@ApiModelProperty(value = "地址")
private String address;
/** 是否紧急:0:否,1:是 */
@ApiModelProperty(value = "是否特殊申请")
private Integer ifEmergency;
/** 申请状态:0:已申请,1:已通过,2:已驳回,3:已关闭 */
@ApiModelProperty(value = "审核状态")
private Long checkStatus;
/**
* 数据状态
*/
private String dataStatus;
/**
* 数据异常信息
*/
private String errorMessage;
}
package com.boco.nbd.wios.manage.entity.dto;
import lombok.Data;
/**
* <p>
* 墙盒申请状态查询参数
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyDetailQueryDTO {
private String orderId;
private String supplierId;
}
package com.boco.nbd.wios.manage.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
/**
* <p>
* 墙盒申请审核
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyCheckVO {
@ApiModelProperty(value = "数据id", notes = "不是安装订单号", example = "1", required = true)
@NotNull(message = "id不能为空")
private Long id;
@ApiModelProperty(value = "安装订单号", notes = "", example = "CA20201204044558", required = true)
private String orderId;
/** 申请状态:0:已申请,1:已通过,2:已驳回,3:已关闭 */
@ApiModelProperty(value = "审核意见", notes = "1:通过,2:驳回", example = "1", required = true)
@NotNull(message = "审核意见不能为空")
private Long checkStatus;
@ApiModelProperty(value = "审核备注", notes = "", example = "同意", required = true)
private String checkRemarks;
}
package com.boco.nbd.wios.manage.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* 墙盒申请详情页面
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyDetailVO {
/**
* t_order数据
*/
@ApiModelProperty(value = "客户姓名")
private String userName;
@ApiModelProperty(value = "联系电话")
private String userPhone;
@ApiModelProperty(value = "安装单号")
private String orderId;
@ApiModelProperty(value = "墙盒设备型号")
private String itemModel;
@ApiModelProperty(value = "墙盒设备编号")
private String wallboxCode;
@ApiModelProperty(value = "墙盒品牌")
private String wallboxModel;
/**
* t_wallbox_apply
*/
@ApiModelProperty(value = "物流单号")
private String trackingNumber;
@ApiModelProperty(value = "物流状态0未发货,1已发货")
private String trackingStatus;
@ApiModelProperty(value = "墙盒是否申请")
private String checkStatus;
/**
* t_delivery
*/
@ApiModelProperty(value = "物流供应商")
private String logisticCompany;
/**
* 物流接口
*/
//发货客户名称
private String shipperName;
//发货联系人名称
private String contactName;
//联系人手机
private String contactMobile;
//收货人联系姓名
private String receiverCustName;
//接货人联系手机
private String receiveMobile;
//接货人联系电话
private String receivePhone;
}
package com.boco.nbd.wios.manage.entity.vo;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.starcharge.wios.validation.CreateEntityGroup;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/**
* <p>
* 墙盒申请excel
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyExcelVO {
/** 安装订单号 */
@ExcelProperty("安装订单号")
@NotNull(groups = CreateEntityGroup.class,message = "缺少安装单号")
@NotEmpty(groups = CreateEntityGroup.class,message = "缺少安装单号")
private String orderId;
/** 墙盒设备型号(对应物料id) */
@ExcelIgnore
private String wallboxItemId;
@ExcelIgnore
private String wallboxModel;
/** 是否紧急:0:否,1:是 */
@ExcelProperty("是否紧急(0否,1是)")
@NotNull(groups = CreateEntityGroup.class,message = "缺少是否紧急数据")
private Integer ifEmergency;
/**
* 错误信息
*/
@ExcelIgnore
private String errorMessage;
}
package com.boco.nbd.wios.manage.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 墙盒申请安装团队
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyInstallInfoVO {
/** 自增id */
private Long id;
/** 安装订单号 */
@ApiModelProperty(value = "安装订单号")
private String orderId;
@ApiModelProperty(value = "安装状态")
private String installStatus;
/** 安装服务商id */
@ApiModelProperty(value = "安装服务商id")
private String supplierId;
/** 申请团队名称 */
@ApiModelProperty(value = "申请团队名称")
private String supplierTeam;
/** 墙盒设备型号(对应物料id) */
@ApiModelProperty(value = "墙盒设备型号(对应物料id)")
private String wallboxItemId;
/** 物料类型 */
@ApiModelProperty(value = "物料类型")
private String materialType;
/** 墙盒品牌*/
@ApiModelProperty(value = "墙盒品牌")
private String wallboxModel;
/** 墙盒类型*/
@ApiModelProperty(value = "墙盒类型")
private String wallboxType;
@ApiModelProperty(value = "预约安装时间")
private String installReserveTime;
/** 区域id */
@ApiModelProperty(value = "区域id")
private String regionId;
@ApiModelProperty(value = "区域名称")
private String regionName;
/** 是否紧急:0:否,1:是 */
@ApiModelProperty(value = "是否特殊申请")
private Integer ifEmergency;
/** 申请状态:0:已申请,1:已通过,2:已驳回,3:已关闭 */
@ApiModelProperty(value = "审核状态")
private Long checkStatus;
/** 创建时间 */
@ApiModelProperty(value = "申请时间")
private Date createdTime;
@ApiModelProperty(value = "审核时间")
private Date checkTime;
@ApiModelProperty(value = "审核人员")
private String checkAccount;
private String checkName;
@ApiModelProperty(value = "审核意见")
private String checkRemarks;
@ApiModelProperty(value = "车企安装单号")
private String outOrderId;
@ApiModelProperty(value = "物流单号")
private String trackingNumber;
/** 物流状态 */
@ApiModelProperty(value = "物流状态")
private String logisticsStatus;
@ApiModelProperty(value = "数量")
private String number;
}
package com.boco.nbd.wios.manage.entity.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 墙盒申请安装团队
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyInstallListVO {
/** 自增id */
private Long id;
/** 安装订单号 */
@ApiModelProperty(value = "安装订单号")
@ExcelProperty("安装订单号")
private String orderId;
@ApiModelProperty(value = "安装状态")
private String installStatus;
/** 安装服务商id */
@ApiModelProperty(value = "安装服务商id")
private String supplierId;
/** 申请团队名称 */
@ApiModelProperty(value = "申请团队名称")
@ExcelProperty("申请团队名称")
private String supplierTeam;
/** 墙盒设备型号(对应物料id) */
@ApiModelProperty(value = "墙盒设备型号(对应物料id)")
private String wallboxItemId;
/** 物料类型 */
@ApiModelProperty(value = "物料类型")
private String materialType;
/** 墙盒品牌*/
@ApiModelProperty(value = "墙盒品牌")
@ExcelProperty("墙盒品牌")
private String wallboxModel;
/** 墙盒类型*/
@ApiModelProperty(value = "墙盒类型")
private String wallboxType;
@ApiModelProperty(value = "剩余时间")
private String timeRemaining;
/** 区域id */
@ApiModelProperty(value = "区域id")
private String regionId;
@ExcelProperty("仓库名称")
private String regionName;
/** 是否紧急:0:否,1:是 */
@ApiModelProperty(value = "是否特殊申请")
private Integer ifEmergency;
/** 是否超时:0:未超时,1:已超时 */
@ApiModelProperty(value = "超时类型")
private Long ifTimeout;
/** 申请状态:0:已申请,1:已通过,2:已驳回,3:已关闭 */
@ApiModelProperty(value = "申请状态")
private Long checkStatus;
/** 创建时间 */
@ApiModelProperty(value = "申请时间")
private Date createdTime;
@ApiModelProperty(value = "物流单号")
private String trackingNumber;
/** 物流状态 */
@ApiModelProperty(value = "物流状态")
private String logisticsStatus;
@ApiModelProperty(value = "数量")
private String number;
}
package com.boco.nbd.wios.manage.entity.vo;
import lombok.Data;
import java.util.Date;
/**
* <p>
* 墙盒申请分页响应结果
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyPageVO {
/** 自增id */
private Long id;
/** 安装订单号 */
private String installationOrderId;
/** 安装服务商id */
private String supplierId;
/** 申请团队名称 */
private String supplierTeam;
/** 墙盒设备型号(对应物料id) */
private String wallboxItemId;
/** 物料类型 */
private String materialType;
/** 墙盒品牌*/
private String wallboxModel;
/** 墙盒类型*/
private String wallboxType;
/** 区域id */
private String regionId;
private Date installReserveTime;
private String outOrderId;
/** 审核备注 */
private String checkRemarks;
/** 是否紧急:0:否,1:是 */
private Integer ifEmergency;
/** 是否超时:0:未超时,1:已超时 */
private Long ifTimeout;
/** 申请状态:0:已申请,1:已通过,2:已驳回,3:已关闭 */
private Long checkStatus;
/** 创建人 */
private String createAccount;
/** 创建时间 */
private Date createdTime;
/** 更新人 */
private String modifyAccount;
/** 更新时间 */
private Date modifyTime;
/** 审核人 */
private String checkAccount;
/** 审核时间 */
private Date checkTime;
/** 物流状态 */
private String logisticsStatus;
}
package com.boco.nbd.wios.manage.entity.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* <p>
* description
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Data
public class WallboxApplyReqVO {
/** 申请团队名称 */
@ApiModelProperty(value = "申请团队名称", required = true)
private String supplierTeam;
/** 区域id */
@ApiModelProperty(value = "区域id", required = true)
private String regionId;
/** 申请状态:0:已申请,1:已通过,2:已驳回,3:已关闭 */
@ApiModelProperty(value = "申请状态", notes = "0:已申请,1:已通过,2:已驳回,3:已关闭", example = "1", required = true)
private Long checkStatus;
/** 墙盒设备型号(对应物料id) */
@ApiModelProperty(value = "墙盒设备型号(对应物料id)", required = false)
private String wallboxItemId;
/** 物流状态0未发货,1已发货 */
@ApiModelProperty(value = "物流状态0未发货,1已发货", required = false)
private String trackingStatus;
}
package com.boco.nbd.wios.manage.mapper.def;
import com.boco.nbd.wios.manage.entity.bo.WallboxApply;
import com.boco.nbd.wios.manage.entity.dto.WallboxApplyDetailQueryDTO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyDetailVO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyInstallInfoVO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyInstallListVO;
import com.ihidea.core.base.CoreDao;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import java.util.List;
/**
* <p>
* 墙盒申请Mapper接口
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
public interface WallboxApplyMapper {
/**
* 查询墙盒申请
*
* @param id 墙盒申请主键
* @return 墙盒申请
*/
WallboxApplyInstallInfoVO selectWallboxApplyById(Long id);
/**
* 墙盒状态
*/
WallboxApplyDetailVO selectWallboxDetail(WallboxApplyDetailQueryDTO query);
/**
* 查询墙盒申请
*
* @param id Order id
* @return 墙盒申请
*/
WallboxApply selectWallboxApplyByOrderId(String id);
/**
* 查询墙盒申请列表
*
* @return 墙盒申请集合
*/
List<WallboxApply> selectWallboxApplyList(WallboxApply WallboxApply);
List<WallboxApplyInstallListVO> selectWallboxApplyListFromOrder(WallboxApply WallboxApply);
/**
* 新增墙盒申请
*
* @param tWallboxApply 墙盒申请
* @return 结果
*/
int insertWallboxApply(WallboxApply WallboxApply);
/**
* 修改墙盒申请
*
* @param tWallboxApply 墙盒申请
* @return 结果
*/
int updateWallboxApply(WallboxApply WallboxApply);
void batchUpdateWallboxApply(List<WallboxApply> list);
/**
* 删除墙盒申请
*
* @param id 墙盒申请主键
* @return 结果
*/
int deleteWallboxApplyById(Long id);
/**
* 批量删除墙盒申请
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
int deleteWallboxApplyByIds(Long[] ids);
/**
* 通过物料编码更新发货状态
*
* @param trackingStatus
* @param wallboxItemId
* @return
*/
@Update("update t_wallbox_apply set tracking_status=#{trackingStatus} where wallbox_item_id=#{wallboxItemId}")
int updateWallBoxTrackingStatusByMC(@Param("trackingStatus") String trackingStatus, @Param("wallboxItemId") String wallboxItemId);
}
......@@ -115,7 +115,11 @@ public class SupplierService {
throw new ServiceException("转换失败");
}
}
public Supplier getById(Integer id){
return supplierDao.selectById(id);
}
public List<SupplierVo> getList(SupplierBo condition) {
SessionInfo sessionInfo = ProcessUtil.getUserInfo();
if (sessionInfo != null && !StringUtils.isEmpty(sessionInfo.getAttribute().get("installSupplierId"))) {
......
package com.boco.nbd.wios.manage.service.impl;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.boco.nbd.wios.manage.entity.bo.Order;
import com.boco.nbd.wios.manage.entity.bo.OrderInstall;
import com.boco.nbd.wios.manage.entity.bo.SupplierStaff;
import com.boco.nbd.wios.manage.entity.bo.WallboxApply;
import com.boco.nbd.wios.manage.entity.dto.WallboxApplyBatchCheckDTO;
import com.boco.nbd.wios.manage.entity.dto.WallboxApplyCheckDTO;
import com.boco.nbd.wios.manage.entity.dto.WallboxApplyDetailQueryDTO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyCheckVO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyDetailVO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyInstallInfoVO;
import com.boco.nbd.wios.manage.entity.vo.WallboxApplyInstallListVO;
import com.boco.nbd.wios.manage.mapper.def.*;
import com.ihidea.core.support.exception.ServiceException;
import com.ihidea.core.support.session.SessionInfo;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* description
* <p>
*
* @author <a href="mail to: ning.chai@foxmail.com" rel="nofollow">chaining</a>
*/
@Service
public class WallboxApplyService {
@Autowired
private WallboxApplyMapper wallboxApplyMapper;
@Autowired
private OrderDao orderDao;
@Autowired
private OrderInstallDao orderInstallDao;
@Autowired
private TokenService tokenService;
@Autowired
private SupplierDao supplierDao;
@Autowired
private SupplierStaffDao supplierStaffDao;
private final Integer CHECK_STATUS_REJECT = 2;
/**
* 查询墙盒申请
*
* @param id 墙盒申请主键
* @return 墙盒申请
*/
public WallboxApplyInstallInfoVO selectWallboxApplyById(Long id) {
return wallboxApplyMapper.selectWallboxApplyById(id);
}
/**
* 墙盒详情(墙盒状态)
*
* @param orderId 订单id
* @return 墙盒申请
*/
public WallboxApplyDetailVO selectWallboxDetail(String orderId) {
SessionInfo loginUser = tokenService.getUser();
String userId = loginUser.getUserId();
List<SupplierStaff> supplier = supplierStaffDao.selectByAccountId(Integer.valueOf(userId));
WallboxApplyDetailQueryDTO query = new WallboxApplyDetailQueryDTO();
query.setOrderId(orderId);
query.setSupplierId(supplier.stream().findFirst().get().getSupplierId().toString());
return wallboxApplyMapper.selectWallboxDetail(query);
}
/**
* 查询墙盒申请列表
*
* @param WallboxApply 墙盒申请
* @return 墙盒申请
*/
public List<WallboxApply> selectWallboxApplyList(WallboxApply WallboxApply) {
return wallboxApplyMapper.selectWallboxApplyList(WallboxApply);
}
/**
* 根据订单表查询墙盒申请列表
*
* @param WallboxApply 墙盒申请
* @return 墙盒申请
*/
public List<WallboxApplyInstallListVO> selectWallboxApplyListFromOrder(WallboxApply WallboxApply) {
List<WallboxApplyInstallListVO> list =
wallboxApplyMapper.selectWallboxApplyListFromOrder(WallboxApply);
list.stream().map(l->{
return l;
});
return list;
}
public WallboxApply calculateTimeRemaining(WallboxApply wallboxApply) {
return wallboxApply;
}
/**
* 新增墙盒申请
*
* @param req 墙盒申请
* @return 结果
*/
public int insertWallboxApply(WallboxApply req) {
//判断是否可以新增
//validateApplyExists(req.getOrderId());
WallboxApply condition = new WallboxApply();
condition.setOrderId(req.getOrderId());
condition.setCheckStatus(1L);
List<WallboxApply> retList = wallboxApplyMapper.selectWallboxApplyList(condition);
if (CollectionUtils.isNotEmpty(retList)){
throw new ServiceException("存在已审核通过的安装单,无法重复申请");
}
condition.setSupplierId(req.getSupplierId());
List<WallboxApply> retList2 = wallboxApplyMapper.selectWallboxApplyList(condition);
if (CollectionUtils.isNotEmpty(retList2)){
throw new ServiceException("该订单已申请");
}
//补全相关信息
Order order = orderDao.selectById(req.getOrderId());
req.setRegionId(order.getRegionId());
String wallboxModel = order.getWallboxModel();
if (StrUtil.isBlank(wallboxModel)) {
throw new ServiceException("订单数据异常,缺失墙盒信息,请联系系统管理员");
}
req.setWallboxItemId(order.getWallboxModel());
req.setWallboxModel(order.getWallboxModel() == null ? "" : order.getWallboxModel());
req.setOutOrderId(order.getOutOrderId());
req.setInstallReserveTime(order.getInstallReserveTime());
req.setAddress(order.getAddress());
req.setTrackingNumber(order.getShipno());
req.setInstallProcess(Integer.toUnsignedLong(order.getStatus()));
req.setInstallStatus(Integer.toString(order.getStatus()));
req.setOutOrderId(order.getOutOrderId());
return wallboxApplyMapper.insertWallboxApply(req);
}
/**
* 新增墙盒申请
*
* @param orderId 订单号
* @return 结果
*/
public int insertWallboxApply(int orderId) {
//判断订单状态
// orderInstallDao.selectByOrderId()
return 0;
}
/**
* 修改墙盒申请
*
* @return 结果
*/
public int updateWallboxApply(WallboxApply wallboxApply) {
WallboxApply record = wallboxApplyMapper.selectWallboxApplyByOrderId(wallboxApply.getOutOrderId());
// if (!CHECK_STATUS_REJECT.equals(record.getCheckStatus())) {
// throw new ServiceException("非驳回状态订单无法修改信息!");
// }
wallboxApply.setCheckTime(new Date());
return wallboxApplyMapper.updateWallboxApply(wallboxApply);
}
/**
* 审核
* @param req
* @return
*/
public int checkWallboxApply(WallboxApplyCheckVO req){
WallboxApply cond = new WallboxApply();
cond.setOrderId(req.getOrderId());
List<WallboxApply> list = wallboxApplyMapper.selectWallboxApplyList(cond);
List<WallboxApply> filteredList = list.stream()
.filter(l -> l.getCheckStatus() == 2)
.collect(Collectors.toList());
if (!filteredList.isEmpty()) {
throw new ServiceException("同订单已审核");
}
WallboxApply update = new WallboxApply();
update.setId(req.getId());
update.setOrderId(req.getOrderId());
update.setCheckStatus(req.getCheckStatus());
update.setCheckRemarks(req.getCheckRemarks());
update.setCheckTime(new Date());
update.setCheckAccount(tokenService.getUser().getUserId());
return wallboxApplyMapper.updateWallboxApply(update);
}
/**
* 批量审核
*/
public WallboxApplyBatchCheckDTO checkBatch(WallboxApplyBatchCheckDTO req) {
List<WallboxApplyCheckDTO> checkList = req.getCheckList();
List<WallboxApply> toUpdateList = new ArrayList<>();
boolean allowedUpdate = true;
for (WallboxApplyCheckDTO wallboxApply : checkList) {
WallboxApply cond = new WallboxApply();
cond.setOrderId(wallboxApply.getOrderId());
List<WallboxApply> list = wallboxApplyMapper.selectWallboxApplyList(cond);
List<WallboxApply> filteredList = list.stream()
.filter(l -> l.getCheckStatus() == 2)
.collect(Collectors.toList());
if (!filteredList.isEmpty()) {
wallboxApply.setDataStatus("0");
wallboxApply.setErrorMessage("该订单已审核通过");
allowedUpdate = false;
}
if (allowedUpdate){
WallboxApply update = new WallboxApply();
update.setId(wallboxApply.getId());
update.setCheckStatus(req.getCheckStatus());
update.setCheckRemarks(req.getCheckRemarks());
update.setCheckAccount(tokenService.getUser().getUserId());
toUpdateList.add(update);
}
}
if (allowedUpdate){
// 批量更新操作
toUpdateList.forEach(l -> wallboxApplyMapper.updateWallboxApply(l));
}
return req;
}
void validateApplyExists(String id) {
OrderInstall orderInstall = orderInstallDao.selectByOrderId(id);
if (ObjectUtil.isNull(orderInstall)) {
throw new ServiceException("不存在安装单号");
}
}
}
package com.boco.nbd.wios.utils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.List;
/**
* Excel 工具类
*
*/
public class ExcelUtils {
/**
* 将列表以 Excel 响应给前端
*
* @param response 响应
* @param filename 文件名
* @param sheetName Excel sheet 名
* @param head Excel head 头
* @param data 数据列表哦
* @param <T> 泛型,保证 head 和 data 类型的一致性
* @throws IOException 写入失败的情况
*/
public static <T> void write(HttpServletResponse response, String filename, String sheetName,
Class<T> head, List<T> data) throws IOException {
response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
// 输出 Excel
EasyExcel.write(response.getOutputStream(), head)
.autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
.registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度
.sheet(sheetName).doWrite(data);
// 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了
response.setContentType("application/octet-stream;charset=ISO8859-1");
}
public static <T> List<T> read(MultipartFile file, Class<T> head) throws IOException {
return EasyExcel.read(file.getInputStream(), head, null)
.autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
.doReadAllSync();
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论