优化生产权限修改,新增空小板Bug修改

This commit is contained in:
liuzhaotian
2024-07-03 11:44:58 +08:00
parent 22c430ddf4
commit 49a88b2e87
9 changed files with 129 additions and 24 deletions
@@ -36,7 +36,8 @@ public class OptimizePlanController {
@GetMapping("/getPlateListByPlanId")
@Operation(summary = "根据排单id获取板材列表")
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
// @PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<List<PlateOptimize>> getPlateListByPlanId(@Schema(description = "排单id") @RequestParam("planId") Long planId) {
return CommonResult.success(optimizePlanService.getPlateListByPlanId(planId));
}
@@ -44,7 +45,7 @@ public class OptimizePlanController {
@PostMapping("/addRemain")
@Operation(summary = "添加余料板")
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<Boolean> addRemain(@RequestBody @Valid AddRemainReqVO vo){
return CommonResult.success(optimizePlanService.addRemain(vo));
}
@@ -52,35 +53,35 @@ public class OptimizePlanController {
@PostMapping("savePlanPlateResult")
@Operation(summary = "提交保存优化结果文件")
@OperateLog(logArgs = false)
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<Boolean> savePlanPlateResult(SavePlanPlateResult result) {
return CommonResult.success(optimizePlanService.savePlanPlateResult(result));
}
@GetMapping("commit")
@Operation(summary = "开始开料")
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<Boolean> commit(@RequestParam @Valid @NotNull(message = "排单id不能空") Long planId) {
return CommonResult.success(optimizePlanService.commit(planId));
}
@GetMapping("/endCutting")
@Operation(summary = "结束开料")
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<Boolean> endCutting(@RequestParam @Valid @NotNull(message = "排单id不能空") Long planId) {
return success(optimizePlanService.endCutting(planId));
}
@GetMapping("/getOptimizeParam")
@Operation(summary = "获取优化算法参数")
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<OptimizeParamResVO> getOptimizeParam(@RequestParam @Valid @NotNull(message = "排单id不能空") Long planId) {
return CommonResult.success(optimizePlanService.getOptimizeParam(planId));
}
@GetMapping("/getCfData")
@Operation(summary = "获取cfData")
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<OptimizeParamResVO> getCfData(@RequestParam @Valid @NotNull(message = "排单id不能空") Long planId) {
//todo
return CommonResult.success(null);
@@ -100,7 +101,7 @@ public class OptimizePlanController {
@GetMapping("/getOrderSource")
@Operation(summary = "获取生产单源数据")
@PreAuthorize("@ss.hasPermission('production:manager-list:calculate')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<OrderSource> getOrderSource(@Schema(description = "生产单id") @RequestParam(required = false) Long orderId,
@Schema(description = "排单id") @RequestParam(required = false) Long planId,
@Schema(description = "机台Id") @RequestParam("machineId") Long machineId
@@ -112,7 +113,7 @@ public class OptimizePlanController {
@GetMapping("/getLabelDataSourceValue")
@Operation(summary = "获取标签数据源value")
@PreAuthorize("@ss.hasPermission('executor:optimize-plate:create')")
@PreAuthorize("@ss.hasPermission('placeorder:optimize')")
public CommonResult<Map<String,Object>> getLabelDataSourceValue(@Valid GetSourceDataReq req ) {
return CommonResult.success( optimizePlanService.getLabelDataSourceValue(req));
@@ -36,7 +36,7 @@ public class OrderGoodsResp {
private BigDecimal area;
@Schema(description = "板件数量")
private Long num;
private int num;
@Schema(description = "生产单信息")
@@ -127,7 +127,7 @@ public interface PlateMapper extends BaseMapperX<PlateDO> {
List<PlatePage> selectGoodsPage( @Param("orderIds") List<Long> orderIds, @Param("organId") Long organId);
IPage<OrderGoodsResp> selectGoodsList(@Param("page") IPage<OrderGoodsResp> page,@Param("pageReqVO") OrderPageReqVOCopy pageReqVO,@Param("organId") Long organId);
IPage<OrderGoodsResp> selectGoodsList(@Param("page") IPage<OrderGoodsResp> page,@Param("goodsIds") List<Long> goodsIds,@Param("organId") Long organId);
List<OrderIds> selectOrderIds(@Param("orderIds") List<Long> orderIds,@Param("organId") Long organId);
@@ -391,7 +391,7 @@ public class PlanServiceImpl implements PlanService {
public PageResult<OrderGoodsResp> getOrderGoodsPage(OrderPageReqVOCopy pageReqVO) {
PageDTO<OrderRespVOCopy> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
PageDTO<OrderGoodsResp> page = new PageDTO<>(pageReqVO.getPageNo(), pageReqVO.getPageSize());
QueryWrapperX<OrderDO> queryWrapperX = new QueryWrapperX<>();
queryWrapperX
@@ -440,6 +440,13 @@ public class PlanServiceImpl implements PlanService {
for (OrderGoodsResp record : orderGoodsResps.getRecords()) {
record.setNum(orderRespVOCopies.stream().filter(e-> Objects.equals(e.getGoodsId(), record.getGoodsId())).
mapToInt(OrderRespVOCopy::getNum).sum());
record.setArea(orderRespVOCopies.stream().filter(e-> Objects.equals(e.getGoodsId(), record.getGoodsId()))
.map(OrderRespVOCopy::getArea)
.reduce(BigDecimal.ZERO,BigDecimal::add));
record.setOrderIds(orderIdsList.stream().filter(e -> Objects.equals(e.getGoodsId(), record.getGoodsId())).collect(Collectors.toList()));
record.setOrderList(orderRespVOCopies.stream().filter(e -> Objects.equals(e.getGoodsId(), record.getGoodsId())).collect(Collectors.toList()));
}
@@ -266,9 +266,7 @@ public class PlateServiceImpl implements PlateService {
plateDO.setRemark(reqVO.getRemake1() +","+ reqVO.getRemake2());
Long goodsId = goodsMapper.selectId(reqVO.getOrderId(), reqVO.getGoodsId(), getUserOrganId()).getId();
plateDO.setGoodsId(goodsId);
plateDO.setGoodsId(reqVO.getGoodsId());
plateDO.setPlateNo((obtainingTime) + Long.toString(plateNo).substring(2));
@@ -408,6 +408,10 @@
and b.status = 2
and a.deleted = false
and opi.item_id is null
and c.goods_id in
<foreach item="goodsIds" collection="goodsIds" open="(" separator="," close=")">
#{goodsIds}
</foreach>
group by c.goods_id,c.id,b.id ,c.goods_name,c.width,c.height,c.thickness, c.material, c.color;
@@ -4,8 +4,12 @@ package com.cf.imes.module.manage.controller.admin.voice;
import com.cf.imes.framework.common.pojo.CommonResult;
import com.cf.imes.module.manage.controller.admin.voice.vo.VoiceReqVO;
import com.cf.imes.module.manage.service.voice.VoiceService;
import com.jacob.com.Dispatch;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@@ -15,6 +19,8 @@ import javax.validation.Valid;
import org.springframework.web.bind.annotation.RestController;
import java.io.ByteArrayInputStream;
import java.sql.Blob;
@Tag(name = "管理后台 - 语音播报")
@@ -31,19 +37,29 @@ public class VoiceController {
@PostMapping()
@Operation(summary = "语音播报")
@PreAuthorize("@ss.hasPermission('manage:voice:insert')")
public CommonResult<String> voiceAnnouncements(@Valid @RequestBody VoiceReqVO reqVO ) throws Exception {
public CommonResult<ResponseEntity<byte[]>> voiceAnnouncements(@Valid @RequestBody VoiceReqVO reqVO ) throws Exception {
String sourceFile = voiceService.voiceAnnouncements(reqVO.getData());
String gzipFile = sourceFile+".zip";
// 压缩语音文件
voiceService.zipFiles(sourceFile, gzipFile);
ResponseEntity<byte[]> voice = voiceService.getVoice(sourceFile);
// 删除生成的 mp3 文件
voiceService.deleteFiles(sourceFile);
return CommonResult.success(gzipFile);
return CommonResult.success(voice);
// String gzipFile = sourceFile+".zip";
//
// // 压缩语音文件
// voiceService.zipFiles(sourceFile, gzipFile);
//
}
@@ -1,17 +1,29 @@
package com.cf.imes.module.manage.service.voice;
import com.jacob.com.Dispatch;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.ResponseEntity;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.sql.Blob;
import java.sql.SQLException;
public interface VoiceService {
// 生成音频文件
String voiceAnnouncements(String data);
String voiceAnnouncements(String data) throws IOException, SQLException;
// 把生成的音频文件进行压缩
void zipFiles(String sourceFile, String gzipFile) throws IOException;
void deleteFiles(String sourceFile);
ResponseEntity<byte[]> getVoice(String sourceFile);
}
@@ -3,16 +3,36 @@ package com.cf.imes.module.manage.service.voice;
import com.cf.imes.module.manage.config.VocieParameters;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.ComThread;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.ByteArrayResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import com.jacob.activeX.ActiveXComponent;
import com.jacob.com.Dispatch;
import com.jacob.com.Variant;
import javax.sql.rowset.serial.SerialBlob;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.sql.Blob;
import java.sql.SQLException;
import java.util.Objects;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.net.http.WebSocket;
import java.nio.ByteBuffer;
import java.nio.channels.Channels;
@@ -23,6 +43,8 @@ import java.util.Random;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
import static org.aspectj.weaver.tools.cache.SimpleCacheFactory.path;
@Service
@Slf4j
public class VoiceServiceImpl implements VoiceService{
@@ -31,11 +53,13 @@ public class VoiceServiceImpl implements VoiceService{
private VocieParameters vocieParameters;
// static {
// System.loadLibrary("jacob-1.18-x64");
// }
// 生成音频文件
//生成音频文件
@Override
public String voiceAnnouncements(String data) {
@@ -106,6 +130,48 @@ public class VoiceServiceImpl implements VoiceService{
@Override
public ResponseEntity<byte[]> getVoice( String fileName) {
try {
File audioFile = new File(fileName);
if (!audioFile.exists()) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body(null);
}
// 读取文件到字节数组
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
try (FileInputStream fileInputStream = new FileInputStream(audioFile)) {
byte[] buffer = new byte[1024];
int bytesRead;
while ((bytesRead = fileInputStream.read(buffer)) != -1) {
byteArrayOutputStream.write(buffer, 0, bytesRead);
}
}
byte[] audioBytes = byteArrayOutputStream.toByteArray();
ByteArrayResource byteArrayResource = new ByteArrayResource(audioBytes);
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.parseMediaType("audio/mpeg"));
headers.setContentLength(audioBytes.length);
headers.setCacheControl("must-revalidate, post-check=0, pre-check=0");
return new ResponseEntity<>(audioBytes, headers, HttpStatus.OK);
} catch (IOException e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}
/**
* 把生成的音频文件进行压缩
* @param fileNames 需要压缩的文件名称列表(包含相对路径)
@@ -175,4 +241,5 @@ public class VoiceServiceImpl implements VoiceService{
}
}