mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-13 21:32:07 +08:00
余料库接口完善修改
This commit is contained in:
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.cf.imes.module.executor.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum OrderStatusEnum {
|
||||||
|
EMPTY(0, "空生产单"),
|
||||||
|
NEW_ORDER(1, "新单"),
|
||||||
|
IN_PRODUCTION(2, "生产中"),
|
||||||
|
FINISH_PRODUCTION(3, "生产完成");
|
||||||
|
|
||||||
|
private final Integer status;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public boolean equals(Integer status) {
|
||||||
|
return this.status .equals(status) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(OrderStatusEnum enableStatusEnum) {
|
||||||
|
return enableStatusEnum != null && enableStatusEnum.status .equals(this.getStatus()) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
+18
-5
@@ -302,13 +302,26 @@ public class OrderController {
|
|||||||
return success(orderService.importTemplate(file,type));
|
return success(orderService.importTemplate(file,type));
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/printing")
|
@GetMapping("/printingZip")
|
||||||
@Operation(summary = "打印/导出")
|
@Operation(summary = "打印/导出(多文件)")
|
||||||
@Parameter(name = "type", description = "文件类型", required = true, example = "0")
|
@Parameter(name = "type", description = "文件类型", required = true, example = "0")
|
||||||
@PreAuthorize("@ss.hasPermission('executor:order:query')")
|
@PreAuthorize("@ss.hasPermission('executor:order:query')")
|
||||||
@OperateLog(type = EXPORT)
|
@OperateLog(type = EXPORT)
|
||||||
public void getOrderPrinting(@Valid OrderPageReqVO pageReqVO, @RequestParam("type") String type,
|
public void getOrderPrintingZip(@Valid OrderPageReqVO pageReqVO,
|
||||||
HttpServletResponse response) throws IOException {
|
@RequestParam("type") String type,
|
||||||
orderService.getPrintData(pageReqVO,type,response);
|
HttpServletResponse response) throws IOException {
|
||||||
|
orderService.getPrintDataZip(pageReqVO,type,response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/printing")
|
||||||
|
@Operation(summary = "打印/导出(单文件)")
|
||||||
|
@Parameter(name = "type", description = "文件类型", required = true, example = "0")
|
||||||
|
@PreAuthorize("@ss.hasPermission('executor:order:query')")
|
||||||
|
@OperateLog(type = EXPORT)
|
||||||
|
public void getOrderPrinting(
|
||||||
|
// @RequestParam("orderId") Long orderId,
|
||||||
|
@RequestParam("type") String type,
|
||||||
|
HttpServletResponse response) throws IOException {
|
||||||
|
orderService.getPrintData(1797937673478864896L,type,response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
@@ -74,4 +74,7 @@ public class PartGoodsRespVO {
|
|||||||
|
|
||||||
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "29507")
|
@Schema(description = "数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "29507")
|
||||||
private Double num;
|
private Double num;
|
||||||
|
|
||||||
|
@Schema(description = "金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "29507")
|
||||||
|
private Double totalPrice;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
@@ -114,4 +114,13 @@ public interface OrderMapper extends BaseMapperX<OrderDO> {
|
|||||||
.eq(OrderDO::getDeleted, 0)
|
.eq(OrderDO::getDeleted, 0)
|
||||||
.eq(OrderDO::getOrganId, organId));
|
.eq(OrderDO::getOrganId, organId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询单个生产单
|
||||||
|
default OrderDO selectOrderOne(Long id,Long organId) {
|
||||||
|
return selectOne(new LambdaQueryWrapper<OrderDO>()
|
||||||
|
.select(OrderDO::getStatus)
|
||||||
|
.eq(OrderDO::getId, id)
|
||||||
|
.eq(OrderDO::getDeleted, 0)
|
||||||
|
.eq(OrderDO::getOrganId, organId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-2
@@ -155,9 +155,14 @@ public interface OrderService {
|
|||||||
void exportTemplate(HttpServletResponse response, String value);
|
void exportTemplate(HttpServletResponse response, String value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打印/导出数据获取
|
* 打印/导出数据获取 (多文件)
|
||||||
*/
|
*/
|
||||||
void getPrintData(OrderPageReqVO orderPageReqVO, String type,HttpServletResponse response) throws IOException;
|
void getPrintDataZip(OrderPageReqVO orderPageReqVO, String type,HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印/导出数据获取 (单文件)
|
||||||
|
*/
|
||||||
|
void getPrintData(Long orderId, String type,HttpServletResponse response) throws IOException;
|
||||||
|
|
||||||
default String getSavePath() {
|
default String getSavePath() {
|
||||||
ApplicationHome applicationHome = new ApplicationHome(this.getClass());
|
ApplicationHome applicationHome = new ApplicationHome(this.getClass());
|
||||||
|
|||||||
+52
-12
@@ -35,11 +35,13 @@ import com.cf.imes.module.executor.dal.mysql.orderParts.OrderPartsMapper;
|
|||||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
|
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
|
||||||
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
import com.cf.imes.module.executor.dal.mysql.plate.PlateMapper;
|
||||||
import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
|
import com.cf.imes.module.executor.dal.mysql.rawgoods.RawGoodsMapper;
|
||||||
|
import com.cf.imes.module.executor.enums.OrderStatusEnum;
|
||||||
import com.cf.imes.module.executor.util.ExcelWriterUtil;
|
import com.cf.imes.module.executor.util.ExcelWriterUtil;
|
||||||
import com.cf.imes.module.executor.util.deviseData.dataTwo.PlateDetail;
|
import com.cf.imes.module.executor.util.deviseData.dataTwo.PlateDetail;
|
||||||
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataProduction;
|
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiDataProduction;
|
||||||
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiTypeRealize;
|
import com.cf.imes.module.executor.util.fileConversion.admin.api.webcad.ApiTypeRealize;
|
||||||
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelTypeRealize;
|
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.ExcelTypeRealize;
|
||||||
|
import com.cf.imes.module.executor.util.fileConversion.admin.files.excel.OrderPlateImportExcelVO;
|
||||||
import com.cf.imes.module.system.api.application.ApplicationApi;
|
import com.cf.imes.module.system.api.application.ApplicationApi;
|
||||||
import com.cf.imes.module.system.api.dict.DictDataApi;
|
import com.cf.imes.module.system.api.dict.DictDataApi;
|
||||||
import com.cf.imes.module.system.api.dict.dto.DictDataRespDTO;
|
import com.cf.imes.module.system.api.dict.dto.DictDataRespDTO;
|
||||||
@@ -275,13 +277,14 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
public void deleteBodyByOrder(Long orderId, Collection<Long> bodyIds) {
|
public void deleteBodyByOrder(Long orderId, Collection<Long> bodyIds) {
|
||||||
validateOrderExists(orderId);
|
validateOrderExists(orderId);
|
||||||
// 校验生产单的状态 1 为新单状态,才可以修改
|
// 校验生产单的状态 1 为新单状态,才可以修改
|
||||||
if (orderMapper.selectOne(new LambdaQueryWrapper<OrderDO>().eq(OrderDO::getId, orderId).eq(OrderDO::getStatus, 1)).getStatus() == 1) {
|
if (orderMapper.selectOrderOne(orderId, OrganContextHolder.getOrganId()).getStatus() !=
|
||||||
|
OrderStatusEnum.NEW_ORDER.getStatus()) {
|
||||||
throw exception(ORDER_STATUS_ERROR);
|
throw exception(ORDER_STATUS_ERROR);
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isNotEmpty(bodyIds)) {
|
if (CollectionUtils.isNotEmpty(bodyIds)) {
|
||||||
bodyIds.forEach(bodyId -> {
|
bodyIds.forEach(bodyId -> {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateOrderBodyExists(orderId, bodyId);
|
validateOrderBodyExists(orderId, bodyId, OrganContextHolder.getOrganId());
|
||||||
// 删除
|
// 删除
|
||||||
orderBodyMapper.deleteAllByOrderId(orderId, bodyId);
|
orderBodyMapper.deleteAllByOrderId(orderId, bodyId);
|
||||||
});
|
});
|
||||||
@@ -444,11 +447,9 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DictDataRespDTO typographyDTO = dictDataApi.getDictData(DictTypeConstants.TYPOGRAPHY_TYPE, String.valueOf(goodsDO.getGoodsId())).getData();// 排版面
|
|
||||||
Long plateGoods = (Long) identifierGenerator.nextId(null);
|
Long plateGoods = (Long) identifierGenerator.nextId(null);
|
||||||
PlateGoodDO plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class)
|
PlateGoodDO plateGoodDO = BeanUtils.toBean(goodsDO, PlateGoodDO.class)
|
||||||
.setId(plateGoods)
|
.setId(plateGoods)
|
||||||
.setTexture(typographyDTO.getLabel())
|
|
||||||
.setGoodsId(String.valueOf(goodsDO.getGoodsId()));
|
.setGoodsId(String.valueOf(goodsDO.getGoodsId()));
|
||||||
goodsDO.setGoodsId(plateGoodDO.getId());
|
goodsDO.setGoodsId(plateGoodDO.getId());
|
||||||
plateGoodLists.add(plateGoodDO);
|
plateGoodLists.add(plateGoodDO);
|
||||||
@@ -458,15 +459,16 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateOrderBodyExists(Long orderId, Long bodyId) {
|
private void validateOrderBodyExists(Long orderId, Long bodyId, Long organId) {
|
||||||
if (orderBodyMapper.selectCount(new LambdaQueryWrapper<OrderBodyDO>().eq(OrderBodyDO::getOrderId, orderId).eq(OrderBodyDO::getId, bodyId)) == 0) {
|
if (orderBodyMapper.selectCount(new LambdaQueryWrapper<OrderBodyDO>()
|
||||||
|
.eq(OrderBodyDO::getOrderId, orderId)
|
||||||
|
.eq(OrderBodyDO::getId, bodyId)
|
||||||
|
.eq(OrderBodyDO::getOrganId, organId)) == 0) {
|
||||||
throw exception(ORDER_BODY_NOT_EXISTS);
|
throw exception(ORDER_BODY_NOT_EXISTS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private LocalDateTime getAfterDate(LocalDateTime date) {
|
private LocalDateTime getAfterDate(LocalDateTime date) {
|
||||||
// 获取当前日期类型 2024-03-06 16:50:15
|
|
||||||
// 获取当前日期,明确指定时区为业务所在时区,例如Asia/Shanghai
|
|
||||||
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
|
ZonedDateTime now = ZonedDateTime.now(ZoneId.of("UTC"));
|
||||||
LocalDateTime localDateTime = now.toLocalDateTime();
|
LocalDateTime localDateTime = now.toLocalDateTime();
|
||||||
|
|
||||||
@@ -474,12 +476,10 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
// 添加30天
|
// 添加30天
|
||||||
LocalDateTime futureDate = localDateTime.plusDays(DEFAULT_DAYS_TO_ADD);
|
LocalDateTime futureDate = localDateTime.plusDays(DEFAULT_DAYS_TO_ADD);
|
||||||
try {
|
try {
|
||||||
// 考虑到异常处理,使用try-catch块
|
|
||||||
return futureDate;
|
return futureDate;
|
||||||
} catch (DateTimeParseException e) {
|
} catch (DateTimeParseException e) {
|
||||||
// 在实际应用中应该有更详细的错误处理逻辑
|
// 在实际应用中应该有更详细的错误处理逻辑
|
||||||
System.err.println("Error parsing future date: " + e.getMessage());
|
System.err.println("Error parsing future date: " + e.getMessage());
|
||||||
// 根据业务需求,这里可以选择记录日志、抛出自定义异常或进行其他处理
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return date;
|
return date;
|
||||||
@@ -630,7 +630,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getPrintData(OrderPageReqVO orderPageReqVO, String type, HttpServletResponse response) throws IOException {
|
public void getPrintDataZip(OrderPageReqVO orderPageReqVO, String type, HttpServletResponse response) throws IOException {
|
||||||
orderPageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
orderPageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
|
||||||
PageResult<OrderDO> pageResult = orderMapper.selectPage(orderPageReqVO.setOrganId(SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
PageResult<OrderDO> pageResult = orderMapper.selectPage(orderPageReqVO.setOrganId(SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||||
List<OrderDO> orderDOList = pageResult.getList();
|
List<OrderDO> orderDOList = pageResult.getList();
|
||||||
@@ -642,7 +642,19 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
for (OrderDO orderDO : orderDOList) {
|
for (OrderDO orderDO : orderDOList) {
|
||||||
map.putAll(getDataByOrderIdAndType(orderDO, type));
|
map.putAll(getDataByOrderIdAndType(orderDO, type));
|
||||||
}
|
}
|
||||||
ExcelWriterUtil.exportExcel(response, map, getSavePath() + "\\" + type, type);
|
ExcelWriterUtil.exportExcelZip(response, map, getSavePath() + "\\" + type, type);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getPrintData(Long orderId, String type, HttpServletResponse response) throws IOException {
|
||||||
|
// 查询生产单
|
||||||
|
OrderDO orderDO = orderMapper.selectById(orderId);
|
||||||
|
if (orderDO == null) {
|
||||||
|
ExcelWriterUtil.writeErr(response, "生产单查找结果为空", getSavePath() + "\\" + "错误文件.xlsx");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<Long, Object> map = getDataByOrderIdAndType(orderId, type);
|
||||||
|
ExcelWriterUtil.exportExcel(response, orderDO, (List<OrderPlateImportExcelVO>) map.get(orderDO.getId()), getSavePath(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据ype 与 orderId获取相关信息
|
// 根据ype 与 orderId获取相关信息
|
||||||
@@ -673,6 +685,34 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据ype 与 orderId获取相关信息
|
||||||
|
public Map<Long, Object> getDataByOrderIdAndType(Long orderId, String type) {
|
||||||
|
Map<Long, Object> map = new HashMap<>();
|
||||||
|
switch (type) {
|
||||||
|
case "配件明细1-模板.xlsx":// 配件明细
|
||||||
|
map.put(orderId, orderPartsMapper.selectPartDetail(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||||
|
break;
|
||||||
|
case "配件汇总1-模板.xlsx":// 配件汇总
|
||||||
|
map.put(orderId, orderPartsMapper.selectPartAll(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||||
|
break;
|
||||||
|
case "板材明细-按房间-模板.xlsx":
|
||||||
|
break;
|
||||||
|
case "板材明细-按板材-模板.xlsx":
|
||||||
|
map.put(orderId, plateMapper.selectPlateGoodsList(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||||
|
|
||||||
|
break;
|
||||||
|
case "板材汇总-按房间-模板.xlsx":
|
||||||
|
break;
|
||||||
|
case "板材汇总-按板材-模板.xlsx":
|
||||||
|
map.put(orderId, plateMapper.selectPlateGoodsList(orderId, SecurityFrameworkUtils.getLoginUser().getOrganId()));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// 处理默认情况,可以选择忽略或者做其他处理
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
public String getRandomNumber(int length) {
|
public String getRandomNumber(int length) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
|
|||||||
+1
-1
@@ -69,7 +69,7 @@ public class OrderProcessServiceImpl implements OrderProcessService {
|
|||||||
private OrderBodyMapper orderBodyMapper;
|
private OrderBodyMapper orderBodyMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Long createOrderProcess(OrderProcessSaveReqVO createReqVO) {
|
public Long createOrderProcess(OrderProcessSaveReqVO createReqVO) {
|
||||||
// 当生产不为删除时,校验生产单存在
|
// 当生产不为删除时,校验生产单存在
|
||||||
if (orderMapper.selectOrder(createReqVO.getOrderId(), SecurityFrameworkUtils.getLoginUser().getOrganId()).isEmpty()) {
|
if (orderMapper.selectOrder(createReqVO.getOrderId(), SecurityFrameworkUtils.getLoginUser().getOrganId()).isEmpty()) {
|
||||||
|
|||||||
+41
-1
@@ -15,6 +15,7 @@ import javax.servlet.ServletOutputStream;
|
|||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
|
import java.net.URLEncoder;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@@ -97,7 +98,7 @@ public class ExcelWriterUtil {
|
|||||||
outputStream.close();
|
outputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void exportExcel(HttpServletResponse response, Map<OrderDO, Object> map, String filePathErr, String type) throws IOException {
|
public static void exportExcelZip(HttpServletResponse response, Map<OrderDO, Object> map, String filePathErr, String type) throws IOException {
|
||||||
ServletOutputStream outputStream = response.getOutputStream();
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
|
ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream);
|
||||||
|
|
||||||
@@ -136,10 +137,49 @@ public class ExcelWriterUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void exportExcel(HttpServletResponse response,
|
||||||
|
OrderDO orderDO,
|
||||||
|
List<OrderPlateImportExcelVO> list,
|
||||||
|
String filePathErr,
|
||||||
|
String type) throws IOException {
|
||||||
|
//输入流
|
||||||
|
InputStream inputStream = ResourceUtils.getURL(filePathErr+ "\\" + type).openStream();
|
||||||
|
ServletOutputStream outputStream = response.getOutputStream();
|
||||||
|
|
||||||
|
|
||||||
|
//设置输出流和模板信息
|
||||||
|
ExcelWriter excelWriter = EasyExcel.write(outputStream).withTemplate(inputStream).build();
|
||||||
|
WriteSheet writeSheet = EasyExcel.writerSheet().build();
|
||||||
|
|
||||||
|
//开启自动换行,自动换行表示每次写入一条list数据是都会重新生成一行空行,此选项默认是关闭的,需要提前设置为true
|
||||||
|
FillConfig fillConfig = FillConfig.builder().forceNewRow(Boolean.TRUE).build();
|
||||||
|
|
||||||
|
//准备单组和数据
|
||||||
|
Map<String, String> mapOrder = fillOrderData(orderDO);
|
||||||
|
|
||||||
|
excelWriter.fill(mapOrder, writeSheet);
|
||||||
|
|
||||||
|
//列表
|
||||||
|
excelWriter.fill(list, fillConfig, writeSheet);
|
||||||
|
|
||||||
|
//设置文件名的编码格式,防止文件名乱码
|
||||||
|
String fileName = URLEncoder.encode(type.replace("模板",String.valueOf(orderDO.getId())), "UTF-8");
|
||||||
|
//固定写法,设置响应头
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename="+ fileName + ".xlsx");
|
||||||
|
|
||||||
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||||
|
//关流
|
||||||
|
excelWriter.finish();
|
||||||
|
inputStream.close();
|
||||||
|
outputStream.close();
|
||||||
|
}
|
||||||
|
|
||||||
// 填充订单数据
|
// 填充订单数据
|
||||||
private static Map<String, String> fillOrderData(OrderDO order) {
|
private static Map<String, String> fillOrderData(OrderDO order) {
|
||||||
Map<String, String> orderMap = new HashMap<>();
|
Map<String, String> orderMap = new HashMap<>();
|
||||||
orderMap.put("customOrderNo", order.getCustomOrderNo());
|
orderMap.put("customOrderNo", order.getCustomOrderNo());
|
||||||
|
orderMap.put("orderId", order.getId().toString());
|
||||||
|
orderMap.put("orderData", order.getOrderDate().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
|
||||||
orderMap.put("customer", order.getCustomer());
|
orderMap.put("customer", order.getCustomer());
|
||||||
orderMap.put("address", order.getAddress());
|
orderMap.put("address", order.getAddress());
|
||||||
orderMap.put("phoneNumber", order.getPhoneNumber());
|
orderMap.put("phoneNumber", order.getPhoneNumber());
|
||||||
|
|||||||
+1
-1
@@ -113,7 +113,7 @@
|
|||||||
from order_goods a
|
from order_goods a
|
||||||
left join order_plate b on a.goods_id = b.goods_id
|
left join order_plate b on a.goods_id = b.goods_id
|
||||||
left join order_item c on c.order_id = b.order_id
|
left join order_item c on c.order_id = b.order_id
|
||||||
left join order_remain_plate d on a.goods_id = d.goods_id and d.plan_id = c.plan_id
|
left join order_remain_plate d on a.goods_id = d.goods_id and d.plan_id = c.plan_id
|
||||||
where c.plan_id = #{planId}
|
where c.plan_id = #{planId}
|
||||||
GROUP BY a.id, d.id
|
GROUP BY a.id, d.id
|
||||||
|
|
||||||
|
|||||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.cf.imes.module.manage.enums;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public enum RemainPlateUseTypeEnum {
|
||||||
|
|
||||||
|
TYPE_ONE(0, "核销"),
|
||||||
|
TYPE_TWO(1, "排单"),
|
||||||
|
TYPE_THREE(2, "补板");
|
||||||
|
|
||||||
|
private final Integer status;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
public boolean equals(Integer status) {
|
||||||
|
return this.status .equals(status) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean equals(RemainPlateUseTypeEnum enableStatusEnum) {
|
||||||
|
return enableStatusEnum != null && enableStatusEnum.status .equals(this.getStatus()) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
+16
-19
@@ -3,6 +3,7 @@ package com.cf.imes.module.manage.controller.admin.plate;
|
|||||||
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlatePageReqVO;
|
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlatePageReqVO;
|
||||||
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateRespVO;
|
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateRespVO;
|
||||||
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateSaveReqVO;
|
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateSaveReqVO;
|
||||||
|
import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateUptReqVO;
|
||||||
import com.cf.imes.module.manage.dal.dataobject.remainplaten.RemainPlateDO;
|
import com.cf.imes.module.manage.dal.dataobject.remainplaten.RemainPlateDO;
|
||||||
import com.cf.imes.module.manage.service.remainplaten.RemainPlateService;
|
import com.cf.imes.module.manage.service.remainplaten.RemainPlateService;
|
||||||
import io.swagger.v3.oas.annotations.Parameters;
|
import io.swagger.v3.oas.annotations.Parameters;
|
||||||
@@ -41,12 +42,19 @@ public class RemainPlateController {
|
|||||||
private RemainPlateService remainPlateService;
|
private RemainPlateService remainPlateService;
|
||||||
|
|
||||||
@PostMapping("/create")
|
@PostMapping("/create")
|
||||||
@Operation(summary = "创建生产单余料板表")
|
@Operation(summary = "创建生产单余料板表(单个)")
|
||||||
@PreAuthorize("@ss.hasPermission('manage:remain-plate:create')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:create')")
|
||||||
public CommonResult<Long> createRemainPlate(@Valid @RequestBody RemainPlateSaveReqVO createReqVO) {
|
public CommonResult<Long> createRemainPlate(@Valid @RequestBody RemainPlateSaveReqVO createReqVO) {
|
||||||
return success(remainPlateService.createRemainPlate(createReqVO));
|
return success(remainPlateService.createRemainPlate(createReqVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/createMultiple")
|
||||||
|
@Operation(summary = "创建生产单余料板表(多个)")
|
||||||
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:create')")
|
||||||
|
public CommonResult<Boolean> createRemainPlateMultiple(@Valid @RequestBody Set<RemainPlateSaveReqVO> createReqVOS) {
|
||||||
|
return success(remainPlateService.createRemainPlateMultiple(createReqVOS));
|
||||||
|
}
|
||||||
|
|
||||||
@PutMapping("/update")
|
@PutMapping("/update")
|
||||||
@Operation(summary = "更新生产单余料板表")
|
@Operation(summary = "更新生产单余料板表")
|
||||||
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
||||||
@@ -57,31 +65,20 @@ public class RemainPlateController {
|
|||||||
|
|
||||||
@PutMapping("/updateStatus")
|
@PutMapping("/updateStatus")
|
||||||
@Operation(summary = "余料板批量核销")
|
@Operation(summary = "余料板批量核销")
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = "id", description = "余料板id集", required = true),
|
|
||||||
@Parameter(name = "status", description = "修改的状态", required = true , example = "1"),
|
|
||||||
@Parameter(name = "useType", description = "使用类型,0核销,1排单,2补板", required = true , example = "1"),
|
|
||||||
@Parameter(name = "planId", description = "排单 ID", example = "1")
|
|
||||||
})
|
|
||||||
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
||||||
public CommonResult<Boolean> updateRemainPlate(@RequestParam("id") Set<Long> ids,
|
public CommonResult<Boolean> updateRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
|
||||||
@RequestParam("status") Integer status,
|
remainPlateService.updateRemainPlateStatus(updateReqVO.getIds(),
|
||||||
@RequestParam("useType") Integer useType,
|
updateReqVO.getStatus(),
|
||||||
@RequestParam("planId") Long planId) {
|
updateReqVO.getUseType(),
|
||||||
remainPlateService.updateRemainPlateStatus(ids,status,useType,planId);
|
updateReqVO.getPlanId());
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@PutMapping("/revertUpdate")
|
@PutMapping("/revertUpdate")
|
||||||
@Operation(summary = "余料板批量释放")
|
@Operation(summary = "余料板批量释放")
|
||||||
@Parameters({
|
|
||||||
@Parameter(name = "id", description = "余料板id集", required = true),
|
|
||||||
@Parameter(name = "status", description = "修改的状态", required = true , example = "1")
|
|
||||||
})
|
|
||||||
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
@PreAuthorize("@ss.hasPermission('manage:remain-plate:update')")
|
||||||
public CommonResult<Boolean> updateRemainPlate(@RequestParam("id") Set<Long> ids,
|
public CommonResult<Boolean> revertRemainPlate(@RequestBody RemainPlateUptReqVO updateReqVO) {
|
||||||
@RequestParam("status") Integer status) {
|
remainPlateService.revertRemainPlateStatus(updateReqVO.getIds(),updateReqVO.getStatus());
|
||||||
remainPlateService.revertRemainPlateStatus(ids,status);
|
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
@@ -16,6 +16,9 @@ import static com.cf.imes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH
|
|||||||
@ToString(callSuper = true)
|
@ToString(callSuper = true)
|
||||||
public class RemainPlatePageReqVO extends PageParam {
|
public class RemainPlatePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@Schema(description = "ID", example = "16628")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
@Schema(description = "排单 ID", example = "16628")
|
@Schema(description = "排单 ID", example = "16628")
|
||||||
private Long planId;
|
private Long planId;
|
||||||
|
|
||||||
|
|||||||
+4
-8
@@ -23,8 +23,7 @@ public class RemainPlateSaveReqVO {
|
|||||||
@Schema(description = "初始排单 ID")
|
@Schema(description = "初始排单 ID")
|
||||||
private Long initPlanId;
|
private Long initPlanId;
|
||||||
|
|
||||||
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "余料板状态,0未使用,1使用中,2已使用", example = "1")
|
||||||
@NotNull(message = "余料板状态,0未使用,1使用中,2已使用不能为空")
|
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@Schema(description = "是否为开料添加,0否,1是", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
@Schema(description = "是否为开料添加,0否,1是", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
@@ -34,12 +33,10 @@ public class RemainPlateSaveReqVO {
|
|||||||
@Schema(description = "使用类型,0核销,1排单,2补板", example = "0")
|
@Schema(description = "使用类型,0核销,1排单,2补板", example = "0")
|
||||||
private Integer useType;
|
private Integer useType;
|
||||||
|
|
||||||
@Schema(description = "商品 ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "7425")
|
@Schema(description = "商品 ID", example = "7425")
|
||||||
@NotEmpty(message = "商品 ID不能为空")
|
|
||||||
private String goodsId;
|
private String goodsId;
|
||||||
|
|
||||||
@Schema(description = "商品名", requiredMode = Schema.RequiredMode.REQUIRED, example = "晨丰")
|
@Schema(description = "商品名", example = "晨丰")
|
||||||
@NotEmpty(message = "商品名不能为空")
|
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@Schema(description = "材料", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "材料", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
@@ -78,8 +75,7 @@ public class RemainPlateSaveReqVO {
|
|||||||
@Schema(description = "备注", example = "随便")
|
@Schema(description = "备注", example = "随便")
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
@Schema(description = "轮廊数据,Json 串", requiredMode = Schema.RequiredMode.REQUIRED)
|
@Schema(description = "轮廊数据,Json 串")
|
||||||
@NotEmpty(message = "轮廊数据,Json 串不能为空")
|
|
||||||
private String outLineJson;
|
private String outLineJson;
|
||||||
|
|
||||||
}
|
}
|
||||||
+23
@@ -0,0 +1,23 @@
|
|||||||
|
package com.cf.imes.module.manage.controller.admin.plate.vo.remain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
@Schema(description = "管理后台 - 生产单余料板表 order_remain_plate_{N} Response VO")
|
||||||
|
@Data
|
||||||
|
public class RemainPlateUptReqVO {
|
||||||
|
|
||||||
|
@Schema(description = "余料板集", requiredMode = Schema.RequiredMode.REQUIRED, example = "16470")
|
||||||
|
private Set<Long> ids;
|
||||||
|
|
||||||
|
@Schema(description = "余料板状态,0未使用,1使用中", example = "1")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "使用类型,0核销,1排单,2补板", example = "0")
|
||||||
|
private Integer useType;
|
||||||
|
|
||||||
|
@Schema(description = "排单 ID", example = "6628")
|
||||||
|
private Long planId;
|
||||||
|
}
|
||||||
+8
@@ -23,6 +23,14 @@ public interface RemainPlateService {
|
|||||||
*/
|
*/
|
||||||
Long createRemainPlate(@Valid RemainPlateSaveReqVO createReqVO);
|
Long createRemainPlate(@Valid RemainPlateSaveReqVO createReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建生产单余料板表
|
||||||
|
*
|
||||||
|
* @param createReqVOS 创建信息
|
||||||
|
* @return 编号
|
||||||
|
*/
|
||||||
|
Boolean createRemainPlateMultiple(@Valid Set<RemainPlateSaveReqVO> createReqVOS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量核销
|
* 批量核销
|
||||||
*
|
*
|
||||||
|
|||||||
+19
-5
@@ -6,6 +6,7 @@ import com.cf.imes.module.manage.controller.admin.plate.vo.remain.RemainPlateSav
|
|||||||
import com.cf.imes.module.manage.dal.dataobject.remainplaten.RemainPlateDO;
|
import com.cf.imes.module.manage.dal.dataobject.remainplaten.RemainPlateDO;
|
||||||
import com.cf.imes.module.manage.dal.mysql.remainplaten.RemainPlateMapper;
|
import com.cf.imes.module.manage.dal.mysql.remainplaten.RemainPlateMapper;
|
||||||
import com.cf.imes.module.manage.enums.RemainPlateStatusEnum;
|
import com.cf.imes.module.manage.enums.RemainPlateStatusEnum;
|
||||||
|
import com.cf.imes.module.manage.enums.RemainPlateUseTypeEnum;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import com.cf.imes.framework.common.pojo.PageResult;
|
import com.cf.imes.framework.common.pojo.PageResult;
|
||||||
@@ -15,6 +16,7 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@@ -41,19 +43,31 @@ public class RemainPlateServiceImpl implements RemainPlateService {
|
|||||||
return remainPlate.getId();
|
return remainPlate.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean createRemainPlateMultiple(Set<RemainPlateSaveReqVO> createReqVOS) {
|
||||||
|
// 批量插入
|
||||||
|
return remainPlateMapper.insertBatch(Collections.singleton(BeanUtils.toBean(createReqVOS, RemainPlateDO.class)));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateRemainPlateStatus(Set<Long> ids, Integer status, Integer useType,Long planId) {
|
public void updateRemainPlateStatus(Set<Long> ids, Integer status, Integer useType,Long planId) {
|
||||||
//判断是否符合核销标准
|
//判断是否符合核销标准
|
||||||
validateRemainPlateStatus(ids,RemainPlateStatusEnum.UNUSED.getStatus());
|
validateRemainPlateStatus(ids,RemainPlateStatusEnum.IN_USE.getStatus());
|
||||||
//以id为条件批量修改余料库中的状态
|
//以id为条件批量修改余料库中的状态
|
||||||
remainPlateMapper.updateRemainPlateStatus(ids, status, useType, OrganContextHolder.getOrganId(),planId);
|
remainPlateMapper.updateRemainPlateStatus(ids, status, useType, OrganContextHolder.getOrganId(),planId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void revertRemainPlateStatus(Set<Long> ids, Integer status) {
|
public void revertRemainPlateStatus(Set<Long> ids, Integer status) {
|
||||||
// 判断余料的状态 为使用中
|
// 判断余料的状态是否存在使用中
|
||||||
validateRemainPlateStatus(ids,RemainPlateStatusEnum.IN_USE.getStatus());
|
validateRemainPlateStatus(ids,RemainPlateStatusEnum.UNUSED.getStatus());
|
||||||
remainPlateMapper.updateRemainPlateStatus(ids, status, null, OrganContextHolder.getOrganId(),null);
|
// 判断使用类型是否为核销
|
||||||
|
for (Long id : ids) {
|
||||||
|
if (validateRemainPlateUseType(id) != RemainPlateUseTypeEnum.TYPE_ONE.getStatus()) {
|
||||||
|
throw exception(REMAIN_PLATE_USR_TYPE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
remainPlateMapper.updateRemainPlateStatus(ids, status, null, OrganContextHolder.getOrganId(),0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -77,7 +91,7 @@ public class RemainPlateServiceImpl implements RemainPlateService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void deleteRemainPlate(Set<Long> ids) {
|
public void deleteRemainPlate(Set<Long> ids) {
|
||||||
// 判断余料的状态 为使用中
|
// 判断余料的状态是否存在使用中
|
||||||
validateRemainPlateStatus(ids,RemainPlateStatusEnum.IN_USE.getStatus());
|
validateRemainPlateStatus(ids,RemainPlateStatusEnum.IN_USE.getStatus());
|
||||||
// 删除
|
// 删除
|
||||||
remainPlateMapper.deleteBatchIds(ids);
|
remainPlateMapper.deleteBatchIds(ids);
|
||||||
|
|||||||
+1
@@ -259,4 +259,5 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
ErrorCode REMAIN_PLATE_STATUS_USED = new ErrorCode(1_002_038_001, "余料板正在使用中,禁止修改");
|
ErrorCode REMAIN_PLATE_STATUS_USED = new ErrorCode(1_002_038_001, "余料板正在使用中,禁止修改");
|
||||||
ErrorCode REMAIN_PLATE_STATUS_NO_USED = new ErrorCode(1_002_038_001, "余料板未使用");
|
ErrorCode REMAIN_PLATE_STATUS_NO_USED = new ErrorCode(1_002_038_001, "余料板未使用");
|
||||||
|
ErrorCode REMAIN_PLATE_USR_TYPE = new ErrorCode(1_002_038_001, "余料板使用类型为不可核销类型");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user