1.增加导入建垛接口

master
x_z 3 years ago
parent 62b9fdd570
commit 1dbe3957ab

@ -75,6 +75,13 @@ public class StackCodeController {
if (bindingResult.hasErrors()) { if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage()); return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
} }
if (StrUtil.isNotBlank(addStackCodeRequest.getOrderId())) {
//判断此条码是重复添加
boolean result = stackCodeService.repeatAdd(addStackCodeRequest.getCode());
if (result) {
return ResultVOUtils.error(500, "条码重复!");
}
}
StackCode stackCode = stackCodeService.addCode(addStackCodeRequest); StackCode stackCode = stackCodeService.addCode(addStackCodeRequest);
return ResultVOUtils.success(stackCode); return ResultVOUtils.success(stackCode);
} }

@ -1,11 +1,14 @@
package com.glxp.udi.admin.controller.product; package com.glxp.udi.admin.controller.product;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.glxp.udi.admin.annotation.AuthRuleAnnotation; import com.glxp.udi.admin.annotation.AuthRuleAnnotation;
import com.glxp.udi.admin.common.res.BaseResponse; import com.glxp.udi.admin.common.res.BaseResponse;
import com.glxp.udi.admin.req.info.DeleteRequest; import com.glxp.udi.admin.req.info.DeleteRequest;
import com.glxp.udi.admin.req.product.StackUploadRequest; import com.glxp.udi.admin.req.product.StackUploadRequest;
import com.glxp.udi.admin.res.product.StackOrderResponse;
import com.glxp.udi.admin.service.auth.CustomerService; import com.glxp.udi.admin.service.auth.CustomerService;
import com.glxp.udi.admin.common.util.ResultVOUtils; import com.glxp.udi.admin.common.util.ResultVOUtils;
import com.glxp.udi.admin.entity.product.StackOrder; import com.glxp.udi.admin.entity.product.StackOrder;
@ -16,12 +19,12 @@ import com.glxp.udi.admin.service.product.StackOrderService;
import com.glxp.udi.admin.common.enums.ResultEnum; import com.glxp.udi.admin.common.enums.ResultEnum;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@Slf4j @Slf4j
@RestController @RestController
@ -42,9 +45,20 @@ public class StackOrderController {
} }
stackOrderFilterRequest.setCustomerId(customerService.getCustomerId() + ""); stackOrderFilterRequest.setCustomerId(customerService.getCustomerId() + "");
IPage<StackOrder> page = stackOrderService.filterList(stackOrderFilterRequest); IPage<StackOrder> page = stackOrderService.filterList(stackOrderFilterRequest);
PageSimpleResponse<StackOrder> pageSimpleResponse = new PageSimpleResponse<>(); List<StackOrderResponse> responses = new ArrayList<>();
page.getRecords().forEach(stackOrder -> {
StackOrderResponse response = new StackOrderResponse();
BeanUtil.copyProperties(stackOrder, response);
//查询此垛的扫码数量
Long codeNum = stackOrderService.countCode(stackOrder.getOrderId());
response.setCodeNum(codeNum);
responses.add(response);
});
PageSimpleResponse<StackOrderResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(page.getTotal()); pageSimpleResponse.setTotal(page.getTotal());
pageSimpleResponse.setList(page.getRecords()); pageSimpleResponse.setList(responses);
return ResultVOUtils.success(pageSimpleResponse); return ResultVOUtils.success(pageSimpleResponse);
} }
@ -97,4 +111,26 @@ public class StackOrderController {
return ResultVOUtils.success(stackOrderId); return ResultVOUtils.success(stackOrderId);
} }
/**
* excel
*
* @param file
* @return
*/
@AuthRuleAnnotation("")
@PostMapping("/udims/stack/order/importStackOrder")
public BaseResponse importStackOrder(@RequestParam("file") MultipartFile file) {
if (file.isEmpty()) {
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "上传文件不能为空");
}
//保存文件
String fileName = file.getOriginalFilename();
String fileType = fileName.substring(fileName.lastIndexOf("."));
//文件类型判断
if (StrUtil.isBlank(fileType) || (!fileType.equals(".xls") || !fileType.equals(".xlsx"))) {
return ResultVOUtils.error(ResultEnum.DATA_ERROR, "只能上传 xlx 或 xlsx 格式文件");
}
return ResultVOUtils.success();
}
} }

@ -14,4 +14,12 @@ public interface StackCodeDao extends BaseMapper<StackCode> {
* @param orderId * @param orderId
*/ */
void deleteByOrderId(@Param("orderId") String orderId); void deleteByOrderId(@Param("orderId") String orderId);
/**
*
*
* @param orderId
* @return
*/
Long countByOrderId(@Param("orderId") String orderId);
} }

@ -0,0 +1,17 @@
package com.glxp.udi.admin.res.product;
import com.glxp.udi.admin.entity.product.StackOrder;
import lombok.Data;
/**
*
*/
@Data
public class StackOrderResponse extends StackOrder {
/**
*
*/
private Long codeNum;
}

@ -100,4 +100,21 @@ public class StackCodeService {
stackCode.setId(id); stackCode.setId(id);
return stackCode; return stackCode;
} }
/**
*
*
* @param orderId
* @param code
* @return
*/
public boolean repeatAdd(String code) {
QueryWrapper<StackCode> countWrapper = new QueryWrapper<>();
countWrapper.eq("code", code);
Long count = stackCodeDao.selectCount(countWrapper);
if (null != count && count > 0) {
return true;
}
return false;
}
} }

@ -43,7 +43,7 @@ public class StackOrderService {
wrapper.eq(stackOrderFilterRequest.getId() != null, "id", stackOrderFilterRequest.getId()) wrapper.eq(stackOrderFilterRequest.getId() != null, "id", stackOrderFilterRequest.getId())
.eq(StrUtil.isNotBlank(stackOrderFilterRequest.getCustomerId()), "customerId", stackOrderFilterRequest.getCustomerId()) .eq(StrUtil.isNotBlank(stackOrderFilterRequest.getCustomerId()), "customerId", stackOrderFilterRequest.getCustomerId())
.eq(StrUtil.isNotBlank(stackOrderFilterRequest.getOrderId()), "orderId", stackOrderFilterRequest.getOrderId()) .like(StrUtil.isNotBlank(stackOrderFilterRequest.getOrderId()), "orderId", stackOrderFilterRequest.getOrderId())
.eq(stackOrderFilterRequest.getExportStatus() != null, "exportStatus", stackOrderFilterRequest.getExportStatus()) .eq(stackOrderFilterRequest.getExportStatus() != null, "exportStatus", stackOrderFilterRequest.getExportStatus())
.eq(stackOrderFilterRequest.getStatus() != null, "status", stackOrderFilterRequest.getStatus()) .eq(stackOrderFilterRequest.getStatus() != null, "status", stackOrderFilterRequest.getStatus())
.orderByDesc("updateTime"); .orderByDesc("updateTime");
@ -56,7 +56,9 @@ public class StackOrderService {
stackOrderDao.updateById(stackUploadRequest.getStackOrderEntity()); stackOrderDao.updateById(stackUploadRequest.getStackOrderEntity());
//更新码详情 //更新码详情
if (CollUtil.isNotEmpty(stackUploadRequest.getStackCodeEntityList())) { if (CollUtil.isNotEmpty(stackUploadRequest.getStackCodeEntityList())) {
stackUploadRequest.getStackCodeEntityList().forEach(stackCode -> {stackCode.setOrderIdFk(stackUploadRequest.getStackOrderEntity().getOrderId());}); stackUploadRequest.getStackCodeEntityList().forEach(stackCode -> {
stackCode.setOrderIdFk(stackUploadRequest.getStackOrderEntity().getOrderId());
});
SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED); SqlSession batchSession = sqlSessionFactory.openSession(ExecutorType.BATCH, TransactionIsolationLevel.READ_COMMITTED);
StackCodeDao mapper = batchSession.getMapper(StackCodeDao.class); StackCodeDao mapper = batchSession.getMapper(StackCodeDao.class);
List<StackCode> stackCodeEntityList = stackUploadRequest.getStackCodeEntityList(); List<StackCode> stackCodeEntityList = stackUploadRequest.getStackCodeEntityList();
@ -95,4 +97,14 @@ public class StackOrderService {
stackCodeDao.deleteByOrderId(orderId); stackCodeDao.deleteByOrderId(orderId);
} }
/**
*
*
* @param orderId
* @return
*/
public Long countCode(String orderId) {
Long codeNum = stackCodeDao.countByOrderId(orderId);
return codeNum;
}
} }

@ -6,4 +6,9 @@
from stack_code from stack_code
where orderIdFk = #{orderId} where orderIdFk = #{orderId}
</delete> </delete>
<select id="countByOrderId" resultType="java.lang.Long">
select count(*) from stack_code where orderIdFk = #{orderId}
</select>
</mapper> </mapper>
Loading…
Cancel
Save