mirror of
http://192.168.1.205:9980/cf_devdept2/cf_imes_server.git
synced 2026-08-14 13:42:07 +08:00
数据完善
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package com.cf.imes.module.executor.api.orderProcess;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.module.executor.enums.ApiConstants;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
|
@FeignClient(name = ApiConstants.NAME) // TODO 晨丰:fallbackFactory =
|
||||||
|
@Tag(name = "RPC 服务 - 多组织")
|
||||||
|
public interface OrderProcessApi {
|
||||||
|
|
||||||
|
String PREFIX = ApiConstants.PREFIX + "/order-process";
|
||||||
|
|
||||||
|
@GetMapping(PREFIX +"/get")
|
||||||
|
@Operation(summary = "获得生产单中的加工组信息表")
|
||||||
|
@Parameter(name = "id", description = "加工组id", required = true, example = "1024")
|
||||||
|
CommonResult<Boolean> getOrderProcessByProcessGroupId(@RequestParam("id") Long id);
|
||||||
|
}
|
||||||
+2
@@ -56,4 +56,6 @@ public interface ErrorCodeConstants {
|
|||||||
ErrorCode BODY_DATA_ERROR = new ErrorCode(1_002_029_010, "柜体数据获取错误");
|
ErrorCode BODY_DATA_ERROR = new ErrorCode(1_002_029_010, "柜体数据获取错误");
|
||||||
ErrorCode GOODS_DATA_ERROR = new ErrorCode(1_002_029_011, "商品信息获取错误");
|
ErrorCode GOODS_DATA_ERROR = new ErrorCode(1_002_029_011, "商品信息获取错误");
|
||||||
ErrorCode PLATE_DATA_ERROR = new ErrorCode(1_002_029_012, "板材数据获取错误");
|
ErrorCode PLATE_DATA_ERROR = new ErrorCode(1_002_029_012, "板材数据获取错误");
|
||||||
|
ErrorCode FILE_READ_SUCCESS = new ErrorCode(1_002_029_012, "文件读取成功");
|
||||||
|
ErrorCode FILE_READ_ERR = new ErrorCode(1_002_029_012, "文件读取错误");
|
||||||
}
|
}
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package com.cf.imes.module.executor.api.orderProcess;
|
||||||
|
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.process.OrderProcessDO;
|
||||||
|
import com.cf.imes.module.executor.service.process.OrderProcessService;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
|
||||||
|
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
public class OrderProcessServiceImpl implements OrderProcessApi{
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderProcessService orderProcessService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<Boolean> getOrderProcessByProcessGroupId(Long id) {
|
||||||
|
OrderProcessDO plateDO = orderProcessService.getOrderProcessByProcessGroupId(id);
|
||||||
|
if (plateDO == null) {
|
||||||
|
return success(false);
|
||||||
|
}
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
+21
-9
@@ -28,11 +28,13 @@ import com.cf.imes.framework.common.pojo.PageResult;
|
|||||||
import com.cf.imes.framework.common.pojo.CommonResult;
|
import com.cf.imes.framework.common.pojo.CommonResult;
|
||||||
import com.cf.imes.framework.common.util.object.BeanUtils;
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
|
|
||||||
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
import static com.cf.imes.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
import com.cf.imes.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
|
||||||
import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
import static com.cf.imes.framework.operatelog.core.enums.OperateTypeEnum.*;
|
||||||
|
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||||
import com.cf.imes.module.executor.service.order.OrderService;
|
import com.cf.imes.module.executor.service.order.OrderService;
|
||||||
@@ -58,7 +60,7 @@ public class OrderController {
|
|||||||
private OrderService orderService;
|
private OrderService orderService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ExcelReadUtil orderExcelUtil;
|
private ExcelReadUtil excelReadUtil;
|
||||||
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(OrderController.class);
|
private static final Logger log = LoggerFactory.getLogger(OrderController.class);
|
||||||
|
|
||||||
@@ -109,7 +111,7 @@ public class OrderController {
|
|||||||
public void importTemplate(HttpServletResponse response, @RequestParam("type") Integer type) {
|
public void importTemplate(HttpServletResponse response, @RequestParam("type") Integer type) {
|
||||||
try {
|
try {
|
||||||
// path是指想要下载的文件的路径
|
// path是指想要下载的文件的路径
|
||||||
File file = new File(ResourceUtils.getURL("classpath:").getPath() + "\\files\\生产单上传样式.xlsx");
|
File file = new File(ResourceUtils.getURL("classpath:").getPath() + "\\files\\生产单新增Excel模板.xlsx");
|
||||||
log.info(file.getPath());
|
log.info(file.getPath());
|
||||||
// 获取文件名
|
// 获取文件名
|
||||||
String filename = file.getName();
|
String filename = file.getName();
|
||||||
@@ -290,21 +292,31 @@ public class OrderController {
|
|||||||
@RequestParam(value = "type", required = false, defaultValue = "true") Integer type,
|
@RequestParam(value = "type", required = false, defaultValue = "true") Integer type,
|
||||||
HttpServletResponse response) throws IOException {
|
HttpServletResponse response) throws IOException {
|
||||||
|
|
||||||
List<?> list = new ArrayList<>();
|
List<?> list = null;
|
||||||
|
OrderDO orderDO = new OrderDO();
|
||||||
if (type == 0) { //excel
|
if (type == 0) { //excel
|
||||||
// 读取文件
|
// 读取文件
|
||||||
// OrderDO orderDO = orderExcelUtil.changeOrderDO(file).setOrderType(0);
|
excelReadUtil.setErr(0);
|
||||||
|
Map<String, Object> map = excelReadUtil.read(file);
|
||||||
|
System.err.println(excelReadUtil.isErr());
|
||||||
|
// 判断是否读取有误
|
||||||
|
if (excelReadUtil.isErr() > 1) {
|
||||||
|
// 返回文件
|
||||||
|
|
||||||
List<OrderPlateImportExcelVO> orderPlateImportExcelVOS = orderExcelUtil.read(file, OrderPlateImportExcelVO.class,7);
|
excelReadUtil.write(response, (Map<Object, Object>) map.get("order"), (List<OrderPlateImportExcelVO>) map.get("plate"));
|
||||||
|
throw exception(FILE_READ_ERR);
|
||||||
list = orderPlateImportExcelVOS;
|
}else {
|
||||||
|
// 获取数据
|
||||||
System.out.println(list);
|
list = (List<?>) map.get("plate");
|
||||||
|
orderDO = excelReadUtil.changeOrderDO((Map<Object, Object>) map.get("order")).setOrderType(0);
|
||||||
|
}
|
||||||
} else if (type == 1) { // json
|
} else if (type == 1) { // json
|
||||||
|
|
||||||
}else if (type == 2) { // xml
|
}else if (type == 2) { // xml
|
||||||
|
|
||||||
}
|
}
|
||||||
|
orderService.importExcelData(orderDO,list);
|
||||||
|
throw exception(FILE_READ_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/get-goodsList")
|
@GetMapping("/get-goodsList")
|
||||||
|
|||||||
-1
@@ -76,7 +76,6 @@ public class OrderSaveReqVO {
|
|||||||
private String splitter;
|
private String splitter;
|
||||||
|
|
||||||
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
@Schema(description = "备注", requiredMode = Schema.RequiredMode.REQUIRED, example = "你猜")
|
||||||
@NotEmpty(message = "备注不能为空")
|
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
private Boolean deleted;
|
private Boolean deleted;
|
||||||
|
|||||||
+1
-1
@@ -33,7 +33,7 @@ public class ProcessStepDO extends BaseDO {
|
|||||||
/**
|
/**
|
||||||
* 生产单号
|
* 生产单号
|
||||||
*/
|
*/
|
||||||
private Long orderNo;
|
private Long orderId;
|
||||||
/**
|
/**
|
||||||
* 完成时间
|
* 完成时间
|
||||||
*/
|
*/
|
||||||
|
|||||||
+1
-1
@@ -19,7 +19,7 @@ public interface ProcessStepMapper extends BaseMapperX<ProcessStepDO> {
|
|||||||
|
|
||||||
default PageResult<ProcessStepDO> selectPage(ProcessStepPageReqVO reqVO) {
|
default PageResult<ProcessStepDO> selectPage(ProcessStepPageReqVO reqVO) {
|
||||||
return selectPage(reqVO, new LambdaQueryWrapperX<ProcessStepDO>()
|
return selectPage(reqVO, new LambdaQueryWrapperX<ProcessStepDO>()
|
||||||
.eqIfPresent(ProcessStepDO::getOrderNo, reqVO.getOrderNo())
|
.eqIfPresent(ProcessStepDO::getOrderId, reqVO.getOrderNo())
|
||||||
.betweenIfPresent(ProcessStepDO::getFinishTime, reqVO.getFinishTime())
|
.betweenIfPresent(ProcessStepDO::getFinishTime, reqVO.getFinishTime())
|
||||||
.eqIfPresent(ProcessStepDO::getStatus, reqVO.getStatus())
|
.eqIfPresent(ProcessStepDO::getStatus, reqVO.getStatus())
|
||||||
.eqIfPresent(ProcessStepDO::getType, reqVO.getType())
|
.eqIfPresent(ProcessStepDO::getType, reqVO.getType())
|
||||||
|
|||||||
-205
@@ -91,211 +91,6 @@ public class OrderInputProcessor {
|
|||||||
|
|
||||||
public static final String ORDER_PLATE_MODEL = "imes_order_plate_model";
|
public static final String ORDER_PLATE_MODEL = "imes_order_plate_model";
|
||||||
|
|
||||||
|
|
||||||
/* public void input(List<Detail> sourceList, Long orderId) {
|
|
||||||
Long organId = OrganContextHolder.getOrganId();
|
|
||||||
ArrayList<RawGoodsDO> rawGoodsDOS = new ArrayList<>();
|
|
||||||
ArrayList<OrderBodyDO> orderBodyDOS = new ArrayList<>();
|
|
||||||
ArrayList<OrderGroupDO> orderGroupDOS = new ArrayList<>();
|
|
||||||
ArrayList<PlateDO> plateDOS = new ArrayList<>();
|
|
||||||
ArrayList<OrderPartsDO> orderPartsDOS = new ArrayList<>();
|
|
||||||
ArrayList<OrderItemDO> orderItemDOS = new ArrayList<>();
|
|
||||||
ArrayList<OrderModuleExtraDO> orderModuleExtraDOS = new ArrayList<>();
|
|
||||||
ArrayList<OrderModelDO> orderModelDOS = new ArrayList<>();
|
|
||||||
Map<RawGoodsDO, Map<OrderBodyDO, Map<OrderGroupDO, List<Detail>>>> map = sourceList.stream().collect(Collectors.groupingBy(e ->
|
|
||||||
RawGoodsDO.builder()
|
|
||||||
.rawGoodsId(e.getIBoardProdInfo().getGoodsId())
|
|
||||||
.goodsName(e.getIBoardProdInfo().getGoodsName())
|
|
||||||
.material(e.getIBoardProdInfo().getMaterial())
|
|
||||||
.color(e.getIBoardProdInfo().getColor())
|
|
||||||
.brand(e.getIBoardProdInfo().getBrand())
|
|
||||||
.spec(e.getIBoardProdInfo().getSpec())
|
|
||||||
.price(0.0)
|
|
||||||
.orderId(orderId)
|
|
||||||
.build(),
|
|
||||||
Collectors.groupingBy(e ->
|
|
||||||
OrderBodyDO.builder()
|
|
||||||
.orderId(orderId)
|
|
||||||
.roomName(e.getIBoardProdInfo().getRoomsName())
|
|
||||||
.name(e.getIBoardProdInfo().getCabinetsName())
|
|
||||||
.width(e.getWidth())
|
|
||||||
.height(e.getHeight())
|
|
||||||
.depth(e.getDepth())
|
|
||||||
// .multiNum(e.getMultiNum().doubleValue())
|
|
||||||
.filename("")
|
|
||||||
.remark("")
|
|
||||||
.build(),
|
|
||||||
Collectors.groupingBy(e ->
|
|
||||||
OrderGroupDO.builder()
|
|
||||||
.groupTypeId((long) e.getIBoardProdInfo().getSynthesis())
|
|
||||||
.groupTypeName(e.getIBoardProdInfo().getCombinationName())
|
|
||||||
.name(e.getIBoardProdInfo().getSynthesisTypeName())
|
|
||||||
.build()
|
|
||||||
)
|
|
||||||
))
|
|
||||||
);
|
|
||||||
|
|
||||||
map.entrySet().forEach(i -> {
|
|
||||||
|
|
||||||
RawGoodsDO rawGoodsDO = i.getKey();
|
|
||||||
rawGoodsDOS.add(rawGoodsDO);
|
|
||||||
rawGoodsDO.setId(identifierGenerator.nextId(null).longValue());
|
|
||||||
i.getValue().entrySet().forEach(j -> {
|
|
||||||
|
|
||||||
OrderBodyDO orderBodyDO = j.getKey();
|
|
||||||
orderBodyDO.setId(identifierGenerator.nextId(null).longValue());
|
|
||||||
orderBodyDO.setRoomId(identifierGenerator.nextId(null).longValue());
|
|
||||||
Map<OrderGroupDO, List<Detail>> value = j.getValue();
|
|
||||||
Integer reduce = value.values().stream().map(List::size).reduce(0, Integer::sum);
|
|
||||||
int unregularNum = value.values().stream().flatMap(Collection::stream).filter(e -> !e.getIBoardProdInfo().getIsRect()).collect(Collectors.toList()).size();
|
|
||||||
orderBodyDO.setPlateNum(reduce);
|
|
||||||
orderBodyDO.setUnregularNum(unregularNum);
|
|
||||||
orderBodyDOS.add(orderBodyDO);
|
|
||||||
j.getValue().entrySet().forEach(k -> {
|
|
||||||
OrderGroupDO orderGroupDO = k.getKey();
|
|
||||||
orderGroupDO.setId(identifierGenerator.nextId(null).longValue());
|
|
||||||
orderGroupDO.setOrderId(orderId);
|
|
||||||
orderGroupDO.setBodyId(orderBodyDO.getId());
|
|
||||||
orderGroupDOS.add(orderGroupDO);
|
|
||||||
|
|
||||||
//moduleExtra
|
|
||||||
List<PlateModuleExtra> plateExtras = k.getValue().stream().filter(e -> e.getIBoardProdInfo().getGoodType() == 1)
|
|
||||||
.map(e -> PlateModuleExtra.builder()
|
|
||||||
.width(e.getIBoardProdInfo().getWidth())
|
|
||||||
.height(e.getIBoardProdInfo().getHeight())
|
|
||||||
.thickness(e.getIBoardProdInfo().getThickness())
|
|
||||||
.groupType(orderGroupDO.getGroupTypeName())
|
|
||||||
.build()
|
|
||||||
).toList();
|
|
||||||
List<PartsModuleExtra> partsModuleExtras = k.getValue().stream().filter(e -> e.getIBoardProdInfo().getGoodType() == 1)
|
|
||||||
.map(e -> PartsModuleExtra.builder()
|
|
||||||
.name(e.getIBoardProdInfo().getName())
|
|
||||||
.bodyName(e.getIBoardProdInfo().getCabinetsName())
|
|
||||||
.model(e.getIBoardProdInfo().getModel())
|
|
||||||
.spec(e.getIBoardProdInfo().getSpec())
|
|
||||||
.unit(e.getIBoardProdInfo().getUnit())
|
|
||||||
.build()
|
|
||||||
).toList();
|
|
||||||
if (CollectionUtil.isNotEmpty(plateExtras)) {
|
|
||||||
orderModuleExtraDOS.add(
|
|
||||||
OrderModuleExtraDO.builder()
|
|
||||||
.orderId(orderId)
|
|
||||||
.bodyId(orderBodyDO.getId())
|
|
||||||
.roomId(orderBodyDO.getRoomId())
|
|
||||||
.type(1)
|
|
||||||
.extraData(JsonUtils.toJsonString(plateExtras))
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CollectionUtil.isNotEmpty(partsModuleExtras)) {
|
|
||||||
orderModuleExtraDOS.add(
|
|
||||||
OrderModuleExtraDO.builder()
|
|
||||||
.orderId(orderId)
|
|
||||||
.bodyId(orderBodyDO.getId())
|
|
||||||
.roomId(orderBodyDO.getRoomId())
|
|
||||||
.type(2)
|
|
||||||
.extraData(JsonUtils.toJsonString(partsModuleExtras))
|
|
||||||
.build());
|
|
||||||
}
|
|
||||||
|
|
||||||
k.getValue().forEach(e -> {
|
|
||||||
int goodType = e.getIBoardProdInfo().getGoodType();
|
|
||||||
OrderItemDO orderItemDO = new OrderItemDO();
|
|
||||||
orderItemDO.setOrderId(orderId);
|
|
||||||
orderItemDO.setPlanId(0L);
|
|
||||||
orderItemDO.setPackageId(0L);
|
|
||||||
orderItemDO.setGroupId(orderGroupDO.getId());
|
|
||||||
orderItemDO.setRoomId(orderBodyDO.getRoomId());
|
|
||||||
orderItemDO.setBodyId(orderBodyDO.getId());
|
|
||||||
orderItemDO.setNum(e.getIBoardProdInfo().getGoodsNumber());
|
|
||||||
if (goodType == 1) {
|
|
||||||
PlateDO plateDO = PlateDO.builder()
|
|
||||||
.id(identifierGenerator.nextId(null).longValue())
|
|
||||||
// .goodsId(rawGoodsDO.getRawGoodsId())
|
|
||||||
.orderId(orderId)
|
|
||||||
.name(e.getIBoardProdInfo().getName())
|
|
||||||
.plateNo(e.getIBoardProdInfo().getPlateNo())
|
|
||||||
//.type(e.getIBoardProdInfo().)
|
|
||||||
// .goodsId(rawGoodsDO.getRawGoodsId())
|
|
||||||
// .height(new BigDecimal(e.getIBoardProdInfo().getHeight()))
|
|
||||||
// .width(new BigDecimal(e.getIBoardProdInfo().getWidth()))
|
|
||||||
// .thickness(new BigDecimal(e.getIBoardProdInfo().getThickness().toString()))
|
|
||||||
// .splitHeight(new BigDecimal(e.getIBoardProdInfo().getSplitHeight()))
|
|
||||||
// .splitWidth(new BigDecimal(e.getIBoardProdInfo().getSplitWidth()))
|
|
||||||
// .splitThickness(new BigDecimal(e.getIBoardProdInfo().getThickness().toString()))
|
|
||||||
// .sealLeft(new BigDecimal(e.getIBoardProdInfo().getSealLeft()))
|
|
||||||
// .sealRight(new BigDecimal(e.getIBoardProdInfo().getSealRight()))
|
|
||||||
// .sealUp(new BigDecimal(e.getIBoardProdInfo().getSealUp()))
|
|
||||||
// .sealDown(new BigDecimal(e.getIBoardProdInfo().getSealDown()))
|
|
||||||
// .area(new BigDecimal( String.valueOf(e.getIBoardProdInfo().getWidth())).multiply( new BigDecimal(e.getIBoardProdInfo().getHeight())))
|
|
||||||
.texture(e.getIBoardProdInfo().getTexture())
|
|
||||||
.type(0)
|
|
||||||
.holeFace(0)
|
|
||||||
.holeArrange(0)
|
|
||||||
.unregularPointCount(0)
|
|
||||||
.frontHoleCount(0)
|
|
||||||
.frontModelCount(0)
|
|
||||||
.backHoleCount(0)
|
|
||||||
.sideHoleCount(0)
|
|
||||||
.backModelCount(0)
|
|
||||||
.isDoor(false)
|
|
||||||
.openDoorType(e.getIBoardProdInfo().getOpenDoorType())
|
|
||||||
.offsetX(0.0)
|
|
||||||
.offsetY(0.0)
|
|
||||||
.isArcAcross(false)
|
|
||||||
.moduleTypeId(orderBodyDO.getId())
|
|
||||||
.filterType(0)
|
|
||||||
.remark(e.getIBoardProdInfo().getRemark())
|
|
||||||
.isCancel(false)
|
|
||||||
.build();
|
|
||||||
orderItemDO.setPlateId(plateDO.getId());
|
|
||||||
orderItemDO.setPartsId(0L);
|
|
||||||
orderItemDO.setType(1);
|
|
||||||
plateDOS.add(plateDO);
|
|
||||||
orderModelDOS.add(
|
|
||||||
OrderModelDO.builder()
|
|
||||||
.orderId(orderId)
|
|
||||||
.plateId(plateDO.getId())
|
|
||||||
.contourDetail(e.getContourDetail())
|
|
||||||
.pointDetail(e.getPointDetail())
|
|
||||||
.holeDetail(e.getHoleDetail())
|
|
||||||
.rawPointDetail(e.getRawPointDetail())
|
|
||||||
.sideHoleDetail(e.getSideHoleDetail())
|
|
||||||
.sideModelDetail(e.getSideModelDetail())
|
|
||||||
.build());
|
|
||||||
} else {
|
|
||||||
OrderPartsDO orderPartsDO = OrderPartsDO.builder()
|
|
||||||
.id(identifierGenerator.nextId(null).longValue())
|
|
||||||
.orderId(orderId)
|
|
||||||
.goodsId(rawGoodsDO.getRawGoodsId())
|
|
||||||
.name(e.getIBoardProdInfo().getName())
|
|
||||||
.material(e.getIBoardProdInfo().getMaterial())
|
|
||||||
.model(e.getIBoardProdInfo().getModel())
|
|
||||||
.spec(e.getIBoardProdInfo().getSpec())
|
|
||||||
.brand(e.getIBoardProdInfo().getBrand())
|
|
||||||
.factory(e.getIBoardProdInfo().getFactory())
|
|
||||||
.unit(e.getIBoardProdInfo().getUnit())
|
|
||||||
.price(0.0)
|
|
||||||
.isComposite(false)
|
|
||||||
.remark(e.getIBoardProdInfo().getRemark())
|
|
||||||
// .type(0)
|
|
||||||
.build();
|
|
||||||
orderItemDO.setType(2);
|
|
||||||
orderItemDO.setPartsId(orderPartsDO.getId());
|
|
||||||
orderItemDO.setPlateId(0L);
|
|
||||||
orderPartsDOS.add(orderPartsDO);
|
|
||||||
orderItemDOS.add(orderItemDO);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
batchSaveModel(orderModelDOS);
|
|
||||||
batchInsert(rawGoodsDOS, orderBodyDOS, orderGroupDOS, orderPartsDOS, plateDOS, orderModuleExtraDOS, orderItemDOS);
|
|
||||||
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量保存生产单小板五金数据
|
* 批量保存生产单小板五金数据
|
||||||
*
|
*
|
||||||
|
|||||||
+2
@@ -133,4 +133,6 @@ public interface OrderService {
|
|||||||
* @return List<GoodsDO>
|
* @return List<GoodsDO>
|
||||||
*/
|
*/
|
||||||
List<GoodsDO> getGoodsList(Long orderId);
|
List<GoodsDO> getGoodsList(Long orderId);
|
||||||
|
|
||||||
|
void importExcelData(OrderDO orderDO, List<?> list);
|
||||||
}
|
}
|
||||||
+31
-16
@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import cn.smallbun.screw.core.util.CollectionUtils;
|
import cn.smallbun.screw.core.util.CollectionUtils;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||||
|
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
import com.cf.imes.module.executor.controller.admin.order.vo.order.*;
|
||||||
import com.cf.imes.framework.datapermission.core.util.DataPermissionUtils;
|
import com.cf.imes.framework.datapermission.core.util.DataPermissionUtils;
|
||||||
@@ -33,6 +34,7 @@ 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.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.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.system.api.application.ApplicationApi;
|
import com.cf.imes.module.system.api.application.ApplicationApi;
|
||||||
import com.cf.imes.module.system.api.user.AdminUserApi;
|
import com.cf.imes.module.system.api.user.AdminUserApi;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -119,6 +121,12 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
@Resource
|
@Resource
|
||||||
private IdentifierGenerator identifierGenerator;
|
private IdentifierGenerator identifierGenerator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SnowFlakeGenerator snowFlakeGenerator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ExcelTypeRealize excelTypeRealize;
|
||||||
|
|
||||||
private static final int DEFAULT_DAYS_TO_ADD = 30;
|
private static final int DEFAULT_DAYS_TO_ADD = 30;
|
||||||
|
|
||||||
private static final int PARTS_PAGE_MAX = 10;
|
private static final int PARTS_PAGE_MAX = 10;
|
||||||
@@ -378,7 +386,7 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
List<PlateDetail> plateDetail = (List<PlateDetail>) listMap.get("plateDetail");
|
List<PlateDetail> plateDetail = (List<PlateDetail>) listMap.get("plateDetail");
|
||||||
List<OrderItemDO> itemDO = (List<OrderItemDO>) listMap.get("itemDO");
|
List<OrderItemDO> itemDO = (List<OrderItemDO>) listMap.get("itemDO");
|
||||||
|
|
||||||
Map<String, List<?>> map = getPlateGoods(goodsDO);
|
Map<String, List<?>> map = getPlateGoods(goodsDO);// 检验商品板材信息是否存在
|
||||||
goodsDO = (List<GoodsDO>) map.get("goodsDO");
|
goodsDO = (List<GoodsDO>) map.get("goodsDO");
|
||||||
List<PlateGoodDO> plateGoodDOS = (List<PlateGoodDO>) map.get("plateGoodDOLists");
|
List<PlateGoodDO> plateGoodDOS = (List<PlateGoodDO>) map.get("plateGoodDOLists");
|
||||||
validateCustomOrderNoExists(order.get(0).getCustomOrderNo());
|
validateCustomOrderNoExists(order.get(0).getCustomOrderNo());
|
||||||
@@ -397,7 +405,6 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
.eq(GoodsDO::getOrderId, orderId)
|
.eq(GoodsDO::getOrderId, orderId)
|
||||||
.eq(GoodsDO::getDeleted, false));
|
.eq(GoodsDO::getDeleted, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, List<?>> getPlateGoods(List<GoodsDO> goodsLists) {
|
private Map<String, List<?>> getPlateGoods(List<GoodsDO> goodsLists) {
|
||||||
Map<String, List<?>> map = new HashMap<>();
|
Map<String, List<?>> map = new HashMap<>();
|
||||||
List<PlateGoodDO> plateGoodLists = new ArrayList<>();
|
List<PlateGoodDO> plateGoodLists = new ArrayList<>();
|
||||||
@@ -422,20 +429,6 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 合并两个 JSON 对象的方法
|
|
||||||
// public JSONObject mergeJSONObjects(JSONObject object1, JSONObject object2) {
|
|
||||||
// if (object1 == null) {
|
|
||||||
// object1.putAll( object2.getJSONObject("value"));
|
|
||||||
// } else {
|
|
||||||
//// System.out.println("object2 " + object2);
|
|
||||||
//// System.out.println(" object2.getJSONObject(value) " + object2.getJSONObject("value"));
|
|
||||||
// if (object2 != null)
|
|
||||||
// object1.putAll( object2.getJSONObject("value"));
|
|
||||||
// }
|
|
||||||
// System.out.println(" object1 " + object1);
|
|
||||||
// return object1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
public JSONObject mergeJSONObjects(JSONObject object1, JSONObject object2) {
|
public JSONObject mergeJSONObjects(JSONObject object1, JSONObject object2) {
|
||||||
|
|
||||||
// 创建新对象
|
// 创建新对象
|
||||||
@@ -552,4 +545,26 @@ public class OrderServiceImpl implements OrderService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void importExcelData(OrderDO orderDO, List<?> list) {
|
||||||
|
orderDO.setId((Long) snowFlakeGenerator.nextId(null));
|
||||||
|
System.out.println(excelTypeRealize.changeDate(list,orderDO.getId()));
|
||||||
|
|
||||||
|
Map<String, List<?>> listMap = excelTypeRealize.changeDate(list,orderDO.getId());
|
||||||
|
List<RawGoodsDO> rawGoodsDO = (List<RawGoodsDO>) listMap.get("rawGoodsDOS");
|
||||||
|
List<GoodsDO> goodsDO = (List<GoodsDO>) listMap.get("goodsDOS");
|
||||||
|
List<PlateGoodDO> plateGoodDOS = (List<PlateGoodDO>) listMap.get("plateGoodDOS");
|
||||||
|
List<OrderBodyDO> bodyDO = (List<OrderBodyDO>) listMap.get("orderBodyDOS");
|
||||||
|
List<OrderGroupDO> groupDO = (List<OrderGroupDO>) listMap.get("orderGroupDOS");
|
||||||
|
List<PlateDO> plateDO = (List<PlateDO>) listMap.get("plateDOS");
|
||||||
|
List<OrderPartsDO> partsDO = (List<OrderPartsDO>) listMap.get("orderPartsDOS");
|
||||||
|
List<OrderItemDO> itemDO = (List<OrderItemDO>) listMap.get("orderItemDOS");
|
||||||
|
List<OrderModelDO> orderModelDOS = (List<OrderModelDO>) listMap.get("orderModelDOS");
|
||||||
|
validateCustomOrderNoExists(orderDO.getCustomOrderNo());
|
||||||
|
orderInputProcessor.batchInsert(rawGoodsDO, bodyDO, groupDO, partsDO, plateDO, null, itemDO, orderDO,goodsDO,plateGoodDOS);
|
||||||
|
orderInputProcessor.batchSaveModel(orderModelDOS);
|
||||||
|
// System.out.println("plateDO = " + plateDO+ " BeanUtils.toBean(plateDetail, OrderModelDO.class) = " + orderModelDOs);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+8
@@ -41,4 +41,12 @@ public interface OrderProcessService {
|
|||||||
*/
|
*/
|
||||||
OrderProcessDO getOrderProcess(Long orderId);
|
OrderProcessDO getOrderProcess(Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得生产单中工序
|
||||||
|
*
|
||||||
|
* @param processGroupId 工序组Id
|
||||||
|
* @return 生产单工序
|
||||||
|
*/
|
||||||
|
OrderProcessDO getOrderProcessByProcessGroupId(Long processGroupId);
|
||||||
|
|
||||||
}
|
}
|
||||||
+49
-1
@@ -1,7 +1,14 @@
|
|||||||
package com.cf.imes.module.executor.service.process;
|
package com.cf.imes.module.executor.service.process;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.incrementer.IdentifierGenerator;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.processStep.ProcessStepDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.processStepItem.OrderProcessStepItemDO;
|
||||||
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
import com.cf.imes.module.executor.dal.mysql.order.OrderMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.processStep.ProcessStepMapper;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.processStepItem.ProcessStepItemMapper;
|
||||||
import com.cf.imes.module.system.api.process.ProcessGroupApi;
|
import com.cf.imes.module.system.api.process.ProcessGroupApi;
|
||||||
|
import com.cf.imes.module.system.api.process.dto.ProcessListReqDTO;
|
||||||
|
import com.cf.imes.module.system.api.process.dto.ProcessRespDTO;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
@@ -13,6 +20,9 @@ import com.cf.imes.framework.common.util.object.BeanUtils;
|
|||||||
|
|
||||||
import com.cf.imes.module.executor.dal.mysql.process.OrderProcessMapper;
|
import com.cf.imes.module.executor.dal.mysql.process.OrderProcessMapper;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.cf.imes.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
|
import static com.cf.imes.module.executor.enums.ErrorCodeConstants.*;
|
||||||
|
|
||||||
@@ -34,6 +44,15 @@ public class OrderProcessServiceImpl implements OrderProcessService {
|
|||||||
@Resource
|
@Resource
|
||||||
private OrderMapper orderMapper;
|
private OrderMapper orderMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private IdentifierGenerator identifierGenerator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProcessStepMapper processStepMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProcessStepItemMapper processStepItemMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createOrderProcess(OrderProcessSaveReqVO createReqVO) {
|
public Long createOrderProcess(OrderProcessSaveReqVO createReqVO) {
|
||||||
// 校验生产单存在
|
// 校验生产单存在
|
||||||
@@ -49,8 +68,32 @@ public class OrderProcessServiceImpl implements OrderProcessService {
|
|||||||
throw exception(ORDER_PROCESS_EXISTS);
|
throw exception(ORDER_PROCESS_EXISTS);
|
||||||
}
|
}
|
||||||
// 插入
|
// 插入
|
||||||
OrderProcessDO orderProcess = BeanUtils.toBean(createReqVO, OrderProcessDO.class);
|
OrderProcessDO orderProcess = BeanUtils.toBean(createReqVO, OrderProcessDO.class).setId((Long) identifierGenerator.nextId(null));
|
||||||
|
|
||||||
|
//
|
||||||
|
// List<ProcessStepDO> processStepDOS = new ArrayList<>();
|
||||||
|
// List<OrderProcessStepItemDO> orderProcessStepItemDOS = new ArrayList<>();
|
||||||
|
// // 需要获取工序组的具体信息,以及工序组中工序的信息,然后将工序组中工序的信息插入到生产单工序步骤表中
|
||||||
|
// ProcessListReqDTO processListReqDTO = processGroupApi.getProcessGroupDetail(createReqVO.getGroupId());
|
||||||
|
// System.err.println(processListReqDTO);
|
||||||
|
// processListReqDTO.getLists().forEach(processRespDTO -> {
|
||||||
|
// ProcessStepDO processStepDO = BeanUtils.toBean(processRespDTO, ProcessStepDO.class).setOrderId(createReqVO.getOrderId())
|
||||||
|
// .setStatus(false).setProcessinfoId(processRespDTO.getId()).setOrderProcessId(orderProcess.getId())
|
||||||
|
// .setId((Long) identifierGenerator.nextId(null));// 计划日期没有填写
|
||||||
|
// processStepDOS.add(processStepDO);
|
||||||
|
// OrderProcessStepItemDO orderProcessStepItemDO = OrderProcessStepItemDO.builder()
|
||||||
|
// .name(processRespDTO.getName())
|
||||||
|
// .processStepId(processRespDTO.getId())
|
||||||
|
// .orderProcessId(orderProcess.getId())
|
||||||
|
// .status(false)
|
||||||
|
// .groupName(processListReqDTO.getName())
|
||||||
|
// .build();// 查模块id,柜体id,加工组id
|
||||||
|
// orderProcessStepItemDOS.add(orderProcessStepItemDO);
|
||||||
|
// });
|
||||||
|
// 批量插入
|
||||||
orderProcessMapper.insert(orderProcess);
|
orderProcessMapper.insert(orderProcess);
|
||||||
|
// processStepMapper.insertBatch(processStepDOS);
|
||||||
|
// processStepItemMapper.insertBatch(orderProcessStepItemDOS);
|
||||||
// 返回
|
// 返回
|
||||||
return orderProcess.getId();
|
return orderProcess.getId();
|
||||||
}
|
}
|
||||||
@@ -88,4 +131,9 @@ public class OrderProcessServiceImpl implements OrderProcessService {
|
|||||||
return orderProcessMapper.selectOne("order_id", orderId);
|
return orderProcessMapper.selectOne("order_id", orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OrderProcessDO getOrderProcessByProcessGroupId(Long processGroupId) {
|
||||||
|
return orderProcessMapper.selectOne("group_id", processGroupId);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
+3
@@ -27,6 +27,9 @@ public class PartsInfo {
|
|||||||
// 柜体成倍拆单的倍数
|
// 柜体成倍拆单的倍数
|
||||||
private Integer multiNum;
|
private Integer multiNum;
|
||||||
|
|
||||||
|
// 单个配件的数量
|
||||||
|
private Double partNum;
|
||||||
|
|
||||||
// 商品信息
|
// 商品信息
|
||||||
private String goodsNo; // 商品编码
|
private String goodsNo; // 商品编码
|
||||||
private Long goodId; // 商品对应标识
|
private Long goodId; // 商品对应标识
|
||||||
|
|||||||
+22
-87
@@ -3,108 +3,43 @@ package com.cf.imes.module.executor.util.fileConversion.admin.files.excel;
|
|||||||
import com.alibaba.excel.context.AnalysisContext;
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
import com.alibaba.excel.event.AnalysisEventListener;
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
import com.alibaba.excel.exception.ExcelDataConvertException;
|
import com.alibaba.excel.exception.ExcelDataConvertException;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public final class ExcelListener<T> extends AnalysisEventListener<OrderPlateImportExcelVO> {
|
public final class ExcelListener extends AnalysisEventListener<Map<Integer, String>> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自定义用于暂时存储data
|
* 每隔5条存储数据库,实际使用中可以100条,然后清理list ,方便内存回收
|
||||||
* 可以通过实例获取该值
|
|
||||||
*/
|
*/
|
||||||
private List<OrderPlateImportExcelVO> datas = new ArrayList<>();
|
// private static final int BATCH_COUNT = 100;
|
||||||
|
// private List<Map<Integer, String>> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
||||||
|
private List<Map<Integer, String>> cachedDataList = new ArrayList<Map<Integer, String>>();
|
||||||
|
private boolean stopParsing = false; // 添加一个标志位用于控制是否停止解析数据
|
||||||
|
|
||||||
private boolean flag = true;
|
|
||||||
|
|
||||||
private Map<Integer, String> valueMap = new HashMap<>();
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 每解析一行都会回调invoke()方法
|
|
||||||
*
|
|
||||||
* @param data 读取后的数据对象
|
|
||||||
* @param context 内容
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void invoke(OrderPlateImportExcelVO data, AnalysisContext context) {
|
public void invoke(Map<Integer, String> data, AnalysisContext context) {
|
||||||
// 根据列来确定是那一条的数据,然后将错误的数据插入其中
|
log.info("解析到一条数据: {}", JSON.toJSONString(data));
|
||||||
// 这里要判断数据的合法性,不合法的数据直接插入到错误数据中
|
|
||||||
System.err.println(data);
|
if (data.get(0) != null && data.get(0).equals("***")) {
|
||||||
if (data.getGoodType() == 0) {
|
log.info("遇到指定数据 ***, 停止写入!");
|
||||||
data.setResult("商品类型未选择");
|
stopParsing = true;
|
||||||
flag = false;
|
}
|
||||||
} else {
|
|
||||||
if (!data.isValidGoods()){
|
if (!stopParsing) {
|
||||||
data.setResult("商品信息填写有误");
|
data.entrySet().removeIf(entry -> Objects.isNull(entry.getValue()));
|
||||||
flag = false;
|
cachedDataList.add(data);
|
||||||
}
|
|
||||||
if (data.getGoodType() == 1) { //板材
|
|
||||||
// if (!data.isValidRawGoods()) {
|
|
||||||
// data.setResult("板材信息填写有误");
|
|
||||||
// flag = false;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
datas.add(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 读取完后操作
|
|
||||||
*
|
|
||||||
* @param context
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public void doAfterAllAnalysed(AnalysisContext context) {
|
public void doAfterAllAnalysed(AnalysisContext context) {
|
||||||
if (this.flag)
|
log.info("所有数据解析完成!");
|
||||||
log.info("所有数据读取完成");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public List<Map<Integer, String>> getDataLists() {
|
||||||
* 异常方法 (类型转换异常也会执行此方法) (读取一行抛出异常也会执行此方法)
|
return cachedDataList;
|
||||||
*
|
|
||||||
* @param exception
|
|
||||||
* @param context
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
// @Override
|
|
||||||
// public void onException(Exception exception, AnalysisContext context) {
|
|
||||||
// this.flag = false;
|
|
||||||
// if (exception instanceof ExcelDataConvertException) {
|
|
||||||
// ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception;
|
|
||||||
// log.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex() + 1,
|
|
||||||
// excelDataConvertException.getColumnIndex() + 1, excelDataConvertException.getCellData());
|
|
||||||
// valueMap.put(excelDataConvertException.getRowIndex() + 1 , String.valueOf(new RuntimeException("第" + (excelDataConvertException.getRowIndex() + 1) + "行" +
|
|
||||||
// ",第" + (excelDataConvertException.getColumnIndex() + 1) + "列数据格式有误,读取失败")));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回数据
|
|
||||||
*
|
|
||||||
* @return 返回读取的数据集合
|
|
||||||
**/
|
|
||||||
public List<OrderPlateImportExcelVO> getDatas() {
|
|
||||||
return datas;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回读取结果
|
|
||||||
*
|
|
||||||
* @return 是否读取成功
|
|
||||||
**/
|
|
||||||
public boolean getFlag() {
|
|
||||||
return flag;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 返回错误信息
|
|
||||||
*
|
|
||||||
* @return String
|
|
||||||
**/
|
|
||||||
public Map<Integer, String> getValueMap() {
|
|
||||||
return valueMap;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
+437
-148
@@ -2,8 +2,17 @@ package com.cf.imes.module.executor.util.fileConversion.admin.files.excel;
|
|||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
|
||||||
|
import com.alibaba.excel.ExcelWriter;
|
||||||
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
||||||
|
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.nacos.common.utils.DateFormatUtils;
|
import com.alibaba.nacos.common.utils.DateFormatUtils;
|
||||||
|
import com.alibaba.nacos.common.utils.StringUtils;
|
||||||
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
import com.cf.imes.module.executor.dal.dataobject.order.OrderDO;
|
||||||
|
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.enums.DictTypeConstants;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
import org.apache.poi.hssf.usermodel.HSSFDateUtil;
|
||||||
import org.apache.poi.ss.usermodel.Cell;
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
@@ -11,11 +20,17 @@ import org.apache.poi.xssf.usermodel.XSSFRow;
|
|||||||
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.ResourceUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.io.IOException;
|
import javax.annotation.Resource;
|
||||||
import java.io.InputStream;
|
import javax.servlet.ServletOutputStream;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.*;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.text.DecimalFormat;
|
import java.text.DecimalFormat;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -27,10 +42,17 @@ public class ExcelReadUtil { // 文件读取
|
|||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
private ExcelListener<OrderPlateImportExcelVO> excelListener = new ExcelListener();
|
private Boolean index = true;
|
||||||
|
|
||||||
public List<OrderPlateImportExcelVO> read(MultipartFile file, Class<OrderPlateImportExcelVO> head, Integer index) throws IOException {
|
private int isErr;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private DictDataApi dictDataApi;
|
||||||
|
|
||||||
|
// 读excel
|
||||||
|
public Map<String, Object> read(MultipartFile file) throws IOException {
|
||||||
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
ExcelListener excelListener = new ExcelListener();
|
||||||
if (file.isEmpty()) {
|
if (file.isEmpty()) {
|
||||||
value = "文件为空";
|
value = "文件为空";
|
||||||
throw new IOException("文件为空");
|
throw new IOException("文件为空");
|
||||||
@@ -44,169 +66,436 @@ public class ExcelReadUtil { // 文件读取
|
|||||||
value = "文件大小为 0";
|
value = "文件大小为 0";
|
||||||
throw new IOException("文件大小为 0");
|
throw new IOException("文件大小为 0");
|
||||||
} else {
|
} else {
|
||||||
|
// 读文件
|
||||||
|
EasyExcel.read(file.getInputStream(), excelListener).headRowNumber(-1).sheet().doRead();
|
||||||
|
|
||||||
List<OrderPlateImportExcelVO> list = new ArrayList<>();
|
Map<Object, Object> orderMap = new HashMap<>();// order
|
||||||
|
List<Map<Integer, String>> dataLists = excelListener.getDataLists();// 读取的内容
|
||||||
|
List<OrderPlateImportExcelVO> list = new ArrayList<>();// plate
|
||||||
|
|
||||||
EasyExcel.read(file.getInputStream(), excelListener).sheet().doRead();
|
dataLists.forEach(
|
||||||
|
item -> {
|
||||||
|
if (item.get(0).equals("###")) {
|
||||||
|
index = false;
|
||||||
|
}
|
||||||
|
if (index) {
|
||||||
|
System.out.println(item);
|
||||||
|
orderMap.put(item.get(0), item.get(1));
|
||||||
|
orderMap.put(item.get(12), item.get(13));
|
||||||
|
} else {
|
||||||
|
if (!(item.get(0).equals("序号") || item.get(0).equals("###"))) {
|
||||||
|
list.add(changeValue(item));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
return list;
|
}
|
||||||
|
);
|
||||||
|
index = true;
|
||||||
|
map.put("order", orderMap);
|
||||||
|
System.err.println(map.get("order"));
|
||||||
|
map.put("plate", list);
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// order 数据转换
|
||||||
|
public OrderDO changeOrderDO(Map<Object, Object> orderMap){
|
||||||
|
String s = (String) orderMap.get("出货日期");
|
||||||
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||||
|
LocalDate orderDate = LocalDate.parse(s, formatter);
|
||||||
|
|
||||||
// // 获取单元格数据
|
OrderDO orderDO = OrderDO.builder()
|
||||||
// public Map<Object, Object> changeValue(InputStream file) throws IOException {
|
.customer((String) orderMap.get("客户"))
|
||||||
// Map<Object, Object> map = new HashMap<>();
|
.customOrderNo((String) orderMap.get("自定义单号"))
|
||||||
//
|
.dealer((String) orderMap.get("经销商"))
|
||||||
// //获取工作簿
|
.dealerPhoneNumber((String) orderMap.get("经销商电话"))
|
||||||
// XSSFWorkbook book = new XSSFWorkbook(file);
|
.address((String) orderMap.get("客户地址"))
|
||||||
// //获取工作表
|
.phoneNumber((String) orderMap.get("客户电话"))
|
||||||
// XSSFSheet sheet = book.getSheetAt(0);
|
.salesman((String) orderMap.get("业务员"))
|
||||||
// int lastRowNum = sheet.getLastRowNum();
|
.deliveryDate(orderDate.atStartOfDay())
|
||||||
//
|
.splitter((String) orderMap.get("拆单员"))
|
||||||
// List<Object> objects = new ArrayList<>();
|
.remark((String) orderMap.get("备注"))
|
||||||
// Map<Object, Object> objectMap = new HashMap<>();
|
.build();
|
||||||
// List<List<Object>> objList = new ArrayList<>();
|
|
||||||
// boolean index = true;
|
|
||||||
//int a = 0;
|
|
||||||
// for (int i = 0; i < lastRowNum; i++) {
|
|
||||||
// //获取单元格
|
|
||||||
// XSSFRow row = sheet.getRow(i);
|
|
||||||
// if (row != null) {
|
|
||||||
// for (Cell cell : row) {
|
|
||||||
// if (cell != null && !"".equals(cell)) {
|
|
||||||
//
|
|
||||||
// Object result = getValue(cell);
|
|
||||||
//
|
|
||||||
// if (!result.equals("")) {
|
|
||||||
// objects.add(result);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// if (objects.get(0).equals("###"))
|
|
||||||
// index = false;
|
|
||||||
// if (objects.get(0).equals("***"))
|
|
||||||
// break;
|
|
||||||
//
|
|
||||||
//// System.out.println(objects);
|
|
||||||
// if (index){
|
|
||||||
// for (int j = 0; j < objects.size() - 1; j++) {
|
|
||||||
// if (isEven(j)) {//偶数
|
|
||||||
// objectMap.put(objects.get(j), objects.get(j + 1));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }else {
|
|
||||||
// System.out.println(objects.get(0) + ":" +objects);
|
|
||||||
// a++;
|
|
||||||
//// System.out.println(objects);
|
|
||||||
// objList.add(objects);
|
|
||||||
// System.err.println(objList);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// objects.clear();
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//// System.out.println(a);
|
|
||||||
//// System.out.println(objectMap);
|
|
||||||
//// System.err.println(objList);
|
|
||||||
//
|
|
||||||
// return map;
|
|
||||||
// }
|
|
||||||
public OrderDO changeOrderDO(MultipartFile file) throws IOException {
|
|
||||||
OrderDO orderDO = new OrderDO();
|
|
||||||
//获取工作簿
|
|
||||||
XSSFWorkbook book = new XSSFWorkbook(file.getInputStream());
|
|
||||||
//获取工作表
|
|
||||||
XSSFSheet sheet = book.getSheetAt(0);
|
|
||||||
int lastRowNum = sheet.getLastRowNum();
|
|
||||||
|
|
||||||
List<Object> objects = new ArrayList<>();
|
|
||||||
Map<Object, Object> objectMap = new HashMap<>();
|
|
||||||
for (int i = 0; i < lastRowNum; i++) {
|
|
||||||
//获取单元格
|
|
||||||
XSSFRow row = sheet.getRow(i);
|
|
||||||
if (row != null) {
|
|
||||||
for (Cell cell : row) {
|
|
||||||
if (cell != null && !"".equals(cell)) {
|
|
||||||
|
|
||||||
Object result = getValue(cell);
|
|
||||||
|
|
||||||
if (!result.equals(""))
|
|
||||||
objects.add(result);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int j = 0; j < objects.size() - 1; j++) {
|
|
||||||
if (isEven(j)) {//偶数
|
|
||||||
objectMap.put(objects.get(j), objects.get(j + 1));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (objects.get(0).equals("###"))
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
String s = (String) objectMap.get("出货日期");
|
|
||||||
orderDO.setCustomOrderNo((String) objectMap.get("自定义单号"))
|
|
||||||
.setCustomer((String) objectMap.get("客户"))
|
|
||||||
.setDealer((String) objectMap.get("经销商"))
|
|
||||||
.setDealerPhoneNumber((String) objectMap.get("经销商电话"))
|
|
||||||
.setAddress((String) objectMap.get("客户地址"))
|
|
||||||
.setPhoneNumber((String) objectMap.get("客户电话"))
|
|
||||||
.setSalesman((String) objectMap.get("业务员"))
|
|
||||||
.setDeliveryDate(changeTime(s))
|
|
||||||
.setSplitter((String) objectMap.get("拆单员"))
|
|
||||||
.setRemark((String) objectMap.get("备注"));
|
|
||||||
System.out.println(orderDO);
|
|
||||||
|
|
||||||
return orderDO;
|
return orderDO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 数据判断
|
|
||||||
private Object getValue(Cell cell) {
|
|
||||||
Object result = null;
|
|
||||||
switch (cell.getCellType()) {
|
|
||||||
case NUMERIC: //数字
|
|
||||||
result = cell.getNumericCellValue();
|
|
||||||
if (HSSFDateUtil.isCellDateFormatted(cell)) {
|
|
||||||
Date date = cell.getDateCellValue();
|
|
||||||
result = DateFormatUtils.format(date, "yyyy-MM-dd'T'HH:mm:ss");
|
|
||||||
} else {
|
|
||||||
result = cell.getNumericCellValue();
|
|
||||||
DecimalFormat df = new DecimalFormat("0");
|
|
||||||
result = df.format(result);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case BOOLEAN: //Boolean
|
|
||||||
result = cell.getBooleanCellValue();
|
|
||||||
break;
|
|
||||||
case ERROR: //故障
|
|
||||||
result = cell.getErrorCellValue();
|
|
||||||
break;
|
|
||||||
case FORMULA: //公式
|
|
||||||
result = cell.getCellFormula();
|
|
||||||
break;
|
|
||||||
case BLANK: //空值
|
|
||||||
result = "";
|
|
||||||
break;
|
|
||||||
default: //字符串
|
|
||||||
result = cell.getStringCellValue();
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private LocalDateTime changeTime(String dateString) {
|
private LocalDateTime changeTime(String dateString) {
|
||||||
|
|
||||||
// 使用 DateTimeFormatter 解析字符串为 LocalDateTime 对象
|
// 使用 DateTimeFormatter 解析字符串为 LocalDateTime 对象
|
||||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy/MM/dd");
|
||||||
LocalDateTime dateTime = LocalDateTime.parse(dateString, formatter);
|
LocalDateTime dateTime = LocalDateTime.parse(dateString, formatter);
|
||||||
|
|
||||||
// 打印解析后的 LocalDateTime 对象
|
// 打印解析后的 LocalDateTime 对象
|
||||||
System.out.println("Parsed LocalDateTime: " + dateTime);
|
System.out.println("Parsed LocalDateTime: " + dateTime);
|
||||||
return dateTime;
|
return dateTime;
|
||||||
}
|
}
|
||||||
|
// 写excel
|
||||||
|
public void write(HttpServletResponse response,
|
||||||
|
Map<Object, Object> orderMap,
|
||||||
|
List<OrderPlateImportExcelVO> list) throws IOException {
|
||||||
|
|
||||||
private boolean isEven(int num) {
|
// 加载模板
|
||||||
return num % 2 == 0;
|
String filePathErr = ResourceUtils.getURL("classpath:").getPath() + "\\files\\生产单新增Excel模板.xlsx";
|
||||||
|
//输入流
|
||||||
|
// InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("templates/生产单新增Excel模板.xlsx");
|
||||||
|
InputStream inputStream = ResourceUtils.getURL(filePathErr).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();
|
||||||
|
//列表
|
||||||
|
excelWriter.fill(list, fillConfig, writeSheet);
|
||||||
|
|
||||||
|
//准备单组和数据
|
||||||
|
Map<String, String> map = new HashMap<>();
|
||||||
|
map.put("customOrderNo", (String) orderMap.get("customOrderNo"));
|
||||||
|
map.put("customer", (String) orderMap.get("customer"));
|
||||||
|
map.put("address", (String) orderMap.get("address"));
|
||||||
|
map.put("phoneNumber", (String) orderMap.get("phoneNumber"));
|
||||||
|
map.put("remark", (String) orderMap.get("remark"));
|
||||||
|
map.put("splitter", (String) orderMap.get("splitter"));
|
||||||
|
map.put("salesman", (String) orderMap.get("salesman"));
|
||||||
|
map.put("dealerPhoneNumber", (String) orderMap.get("dealerPhoneNumber"));
|
||||||
|
map.put("dealer", (String) orderMap.get("dealer"));
|
||||||
|
|
||||||
|
excelWriter.fill(map, writeSheet);
|
||||||
|
|
||||||
|
// response.addHeader("Baeldung-Example-Header", "Value-HttpServletResponse");
|
||||||
|
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||||
|
//关流
|
||||||
|
excelWriter.finish();
|
||||||
|
inputStream.close();
|
||||||
|
outputStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 赋值单元格数据
|
||||||
|
private OrderPlateImportExcelVO changeValue(Map<Integer, String> dataMap) {
|
||||||
|
OrderPlateImportExcelVO vo = new OrderPlateImportExcelVO();
|
||||||
|
|
||||||
|
for (Map.Entry<Integer, String> entry : dataMap.entrySet()) {
|
||||||
|
Integer key = entry.getKey();
|
||||||
|
String value = entry.getValue();
|
||||||
|
|
||||||
|
switch (key) {
|
||||||
|
case 0:
|
||||||
|
vo.setOrdinal(value);
|
||||||
|
break;
|
||||||
|
case 1:// 类型
|
||||||
|
vo.setGoodType(value);
|
||||||
|
break;
|
||||||
|
case 2:// 物料编码
|
||||||
|
vo.setGoodsId(value);
|
||||||
|
break;
|
||||||
|
case 3:// 商品名称
|
||||||
|
vo.setGoodsName(value);
|
||||||
|
break;
|
||||||
|
case 4:// 材质
|
||||||
|
vo.setMaterial(value);
|
||||||
|
break;
|
||||||
|
case 5:// 颜色
|
||||||
|
vo.setColor(value);
|
||||||
|
break;
|
||||||
|
case 6:// 厂家
|
||||||
|
vo.setFactory(value);
|
||||||
|
break;
|
||||||
|
case 7:// 品牌
|
||||||
|
vo.setBrand(value);
|
||||||
|
break;
|
||||||
|
case 8:// 型号
|
||||||
|
vo.setModel(value);
|
||||||
|
break;
|
||||||
|
case 9:// 规格
|
||||||
|
vo.setSpec(value);
|
||||||
|
break;
|
||||||
|
case 10:// 单位
|
||||||
|
vo.setUnit(value);
|
||||||
|
break;
|
||||||
|
case 11:// 数量
|
||||||
|
vo.setGoodsNumber(value);
|
||||||
|
break;
|
||||||
|
case 12:// 房间
|
||||||
|
vo.setRoomsName(value);
|
||||||
|
break;
|
||||||
|
case 13:// 柜体
|
||||||
|
vo.setCabinetsName(value);
|
||||||
|
break;
|
||||||
|
case 14:// 加工组类型
|
||||||
|
|
||||||
|
vo.setSynthesisTypeName(value);
|
||||||
|
break;
|
||||||
|
case 15:// 加工组名称
|
||||||
|
vo.setCombinationName(value);
|
||||||
|
break;
|
||||||
|
case 16://板名称
|
||||||
|
vo.setName(value);
|
||||||
|
break;
|
||||||
|
case 17:// 自定义板编号
|
||||||
|
vo.setPlateNo(value);
|
||||||
|
break;
|
||||||
|
case 18:// 成品长
|
||||||
|
vo.setHeight(value);
|
||||||
|
break;
|
||||||
|
case 19:// 成品宽
|
||||||
|
vo.setWidth(value);
|
||||||
|
break;
|
||||||
|
case 20:// 拆单长
|
||||||
|
vo.setSplitHeight(value);
|
||||||
|
break;
|
||||||
|
case 21:// 拆单宽
|
||||||
|
vo.setSplitWidth(value);
|
||||||
|
break;
|
||||||
|
case 22:// 厚
|
||||||
|
vo.setThickness(value);
|
||||||
|
break;
|
||||||
|
case 23:// 左封边
|
||||||
|
vo.setSealLeft(value);
|
||||||
|
break;
|
||||||
|
case 24:// 右封边
|
||||||
|
vo.setSealRight(value);
|
||||||
|
break;
|
||||||
|
case 25:// 上封边
|
||||||
|
vo.setSealUp(value);
|
||||||
|
break;
|
||||||
|
case 26:// 下封边
|
||||||
|
vo.setSealDown(value);
|
||||||
|
break;
|
||||||
|
case 27:// 排版面
|
||||||
|
vo.setTypographicFace(value);
|
||||||
|
break;
|
||||||
|
case 28:// 纹路
|
||||||
|
vo.setTexture(value);
|
||||||
|
break;
|
||||||
|
case 29:// 开门方向
|
||||||
|
vo.setOpenDoorType(value);
|
||||||
|
break;
|
||||||
|
case 30://备注1
|
||||||
|
vo.setRemark1(value);
|
||||||
|
break;
|
||||||
|
case 31://备注2
|
||||||
|
vo.setRemark2(value);
|
||||||
|
break;
|
||||||
|
case 32://备注3
|
||||||
|
vo.setRemark3(value);
|
||||||
|
break;
|
||||||
|
case 33://备注4
|
||||||
|
vo.setRemark4(value);
|
||||||
|
break;
|
||||||
|
case 34://备注5
|
||||||
|
vo.setRemark5(value);
|
||||||
|
break;
|
||||||
|
case 35://备注6
|
||||||
|
vo.setRemark6(value);
|
||||||
|
break;
|
||||||
|
case 36://备注7
|
||||||
|
vo.setRemark7(value);
|
||||||
|
break;
|
||||||
|
case 37://备注8
|
||||||
|
vo.setRemark8(value);
|
||||||
|
break;
|
||||||
|
case 38://备注9
|
||||||
|
vo.setRemark9(value);
|
||||||
|
break;
|
||||||
|
case 39://备注10
|
||||||
|
vo.setRemark10(value);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// 处理默认情况,可以选择忽略或者做其他处理
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
checkVO(vo);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// OrderPlateImportExcelVO 数据验证
|
||||||
|
private Boolean checkVO(OrderPlateImportExcelVO vo) {
|
||||||
|
List<String> errList = new ArrayList<>();
|
||||||
|
Boolean flag = true;
|
||||||
|
// 检查非空 类型、数量
|
||||||
|
if (StringUtils.isEmpty(vo.getGoodType()) || StringUtils.isEmpty(vo.getGoodsNumber())) {
|
||||||
|
errList.add("类型、数量不能为空");
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
// 检查商品物料编码或是商品名称、规格、材质、颜色不可全为空
|
||||||
|
if (StringUtils.isEmpty(vo.getGoodsId()) && (StringUtils.isEmpty(vo.getGoodsName()) || StringUtils.isEmpty(vo.getSpec())
|
||||||
|
|| StringUtils.isEmpty(vo.getMaterial()) || StringUtils.isEmpty(vo.getColor()) || StringUtils.isEmpty(vo.getUnit()))) {
|
||||||
|
errList.add("商品物料编码或是商品名称、规格、材质、颜色、单位不可全为空");
|
||||||
|
flag = false;
|
||||||
|
}
|
||||||
|
// 若商品类型为板材,需检查房间、柜体、板名称、成品长、成品宽、拆单长、拆单宽、厚、左封边、右封边、上封边、下封边、排版面、纹路、开门方向不能为空
|
||||||
|
if (StringUtils.equals(vo.getGoodType(), "板材")) {
|
||||||
|
if (StringUtils.isEmpty(vo.getRoomsName()) && StringUtils.isEmpty(vo.getCabinetsName()) && StringUtils.isEmpty(vo.getName())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("房间、柜体、板名称不能为空");
|
||||||
|
}
|
||||||
|
//成品长、成品宽、拆单长、拆单宽、厚、左封边、右封边、上封边、下封边 不能为空
|
||||||
|
if (StringUtils.isEmpty(vo.getHeight()) && StringUtils.isEmpty(vo.getWidth()) && StringUtils.isEmpty(vo.getSplitHeight())
|
||||||
|
&& StringUtils.isEmpty(vo.getSplitWidth()) && StringUtils.isEmpty(vo.getThickness()) && StringUtils.isEmpty(vo.getSealLeft())
|
||||||
|
&& StringUtils.isEmpty(vo.getSealRight()) && StringUtils.isEmpty(vo.getSealUp()) && StringUtils.isEmpty(vo.getSealDown())) {
|
||||||
|
|
||||||
|
flag = false;
|
||||||
|
errList.add("小板轮廓数据不能为空");
|
||||||
|
} else { // 成品长、成品宽、拆单长、拆单宽、厚、左封边、右封边、上封边、下封边 数据类型以及长度验证
|
||||||
|
if (!convertToDouble(vo.getHeight())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("成品长数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getHeight())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("成品长数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!convertToDouble(vo.getWidth())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("成品宽数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getWidth())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("成品宽数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!convertToDouble(vo.getSplitHeight())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("拆单长数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getSplitHeight())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("拆单长数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!convertToDouble(vo.getSplitWidth())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("拆单宽数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getSplitWidth())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("拆单宽数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!convertToDouble(vo.getThickness())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("厚数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getThickness())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("厚数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!convertToDouble(vo.getSealLeft())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("左封边数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getSealLeft())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("左封边数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!convertToDouble(vo.getSealRight())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("右封边数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getSealRight())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("右封边数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!convertToDouble(vo.getSealUp())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("上封边数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getSealUp())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("上封边数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!convertToDouble(vo.getSealDown())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("下封边数据类型错误");
|
||||||
|
} else {
|
||||||
|
if (!checkPrecision(vo.getSealDown())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("下封边数据长度错误");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 排版面、纹路、开门方向
|
||||||
|
if (StringUtils.isEmpty(vo.getTypographicFace()) && StringUtils.isEmpty(vo.getTexture()) && StringUtils.isEmpty(vo.getOpenDoorType())) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("排版面、纹路、开门方向不能为空");
|
||||||
|
} else {
|
||||||
|
DictDataRespDTO typographyDTO = dictDataApi.parseDictData(DictTypeConstants.TYPOGRAPHY_TYPE, vo.getTypographicFace()).getData();// 排版面
|
||||||
|
if (typographyDTO == null) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("排版面数据不存在");
|
||||||
|
} else {
|
||||||
|
vo.setTypographicFace(typographyDTO.getValue());
|
||||||
|
}
|
||||||
|
DictDataRespDTO grainDTO = dictDataApi.parseDictData(DictTypeConstants.GRAIN_TYPE, vo.getTexture()).getData();// 纹路
|
||||||
|
if (grainDTO == null) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("纹路数据不存在");
|
||||||
|
} else {
|
||||||
|
vo.setTexture(grainDTO.getValue());
|
||||||
|
}
|
||||||
|
DictDataRespDTO doorDTO = dictDataApi.parseDictData(DictTypeConstants.DOOR_OPENING_DIRECTIONS, vo.getOpenDoorType()).getData();
|
||||||
|
if (doorDTO == null) {
|
||||||
|
flag = false;
|
||||||
|
errList.add("开门方向数据不存在");
|
||||||
|
} else {
|
||||||
|
vo.setOpenDoorType(doorDTO.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!flag) {
|
||||||
|
isErr++;
|
||||||
|
}
|
||||||
|
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(errList));// 错误列表
|
||||||
|
vo.setResult(String.valueOf(jsonArray));
|
||||||
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数据类型可否转换判断
|
||||||
|
public Boolean convertToDouble(String str) {
|
||||||
|
try {
|
||||||
|
Double.parseDouble(str);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 数据长度判断
|
||||||
|
public boolean checkPrecision(String numberStr) {
|
||||||
|
if (numberStr == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分割整数部分和小数部分
|
||||||
|
String[] parts = numberStr.split("\\.");
|
||||||
|
String integerPart = parts[0];
|
||||||
|
String decimalPart = parts.length > 1 ? parts[1] : "";
|
||||||
|
|
||||||
|
// 检查整数部分位数
|
||||||
|
if (integerPart.length() > 5) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查小数部分位数
|
||||||
|
if (decimalPart.length() > 3) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int isErr() {
|
||||||
|
return isErr;
|
||||||
|
}
|
||||||
|
public void setErr(int isErr) {
|
||||||
|
this.isErr = isErr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+322
@@ -0,0 +1,322 @@
|
|||||||
|
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.mybatis.core.generator.SnowFlakeGenerator;
|
||||||
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.goods.GoodsDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderBody.OrderBodyDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderGroup.OrderGroupDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderItem.OrderItemDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderModuleExtra.OrderModuleExtraDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.orderParts.OrderPartsDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.ordermodel.OrderModelDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.plate.PlateDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.plate.PlateGoodDO;
|
||||||
|
import com.cf.imes.module.executor.dal.dataobject.rawgoods.RawGoodsDO;
|
||||||
|
import com.cf.imes.module.executor.dal.mysql.plate.PlateGoodMapper;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 实现数据格式转换
|
||||||
|
* 使用自带id
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Component
|
||||||
|
public class ExcelTypeRealize {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SnowFlakeGenerator snowFlakeGenerator;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PlateGoodMapper plateGoodMapper;
|
||||||
|
|
||||||
|
// 数据转换 + 错误验证
|
||||||
|
public Map<String, List<?>> changeDate(List<?> list, Long orderId) {
|
||||||
|
|
||||||
|
List<OrderPlateImportExcelVO> excelVOS = (List<OrderPlateImportExcelVO>) list;
|
||||||
|
Map<String, List<?>> map = new HashMap<>();
|
||||||
|
|
||||||
|
Long organId = OrganContextHolder.getOrganId();
|
||||||
|
ArrayList<RawGoodsDO> rawGoodsDOS = new ArrayList<>();
|
||||||
|
ArrayList<GoodsDO> goodsDOS = new ArrayList<>();
|
||||||
|
ArrayList<PlateGoodDO> plateGoodDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderBodyDO> orderBodyDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderGroupDO> orderGroupDOS = new ArrayList<>();
|
||||||
|
ArrayList<PlateDO> plateDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderPartsDO> orderPartsDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderItemDO> orderItemDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderModuleExtraDO> orderModuleExtraDOS = new ArrayList<>();
|
||||||
|
ArrayList<OrderModelDO> orderModelDOS = new ArrayList<>();
|
||||||
|
|
||||||
|
HashMap<String, List<OrderPlateImportExcelVO>> checkMap = classifyGoods(excelVOS);
|
||||||
|
|
||||||
|
Map<String, List<OrderPlateImportExcelVO>> goodsIdMap = checkMap.get("plate").stream().collect(
|
||||||
|
Collectors.groupingBy(
|
||||||
|
excelVO -> excelVO.getGoodsId() != null ? excelVO.getGoodsId() : " ",
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
goodsIdMap.forEach((key, value) -> {
|
||||||
|
if (value.get(0).getGoodsId() == null) { // 没有商品编号的
|
||||||
|
// 将相同条件的元素归为一个集合
|
||||||
|
Map<List<Object>, List<OrderPlateImportExcelVO>> goodsMap = value.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
p -> Arrays.asList(p.getGoodsName(),
|
||||||
|
p.getMaterial(),
|
||||||
|
p.getColor(),
|
||||||
|
p.getSpec(),
|
||||||
|
p.getThickness()),
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
|
||||||
|
goodsMap.forEach((goodKey, goodValue) -> {
|
||||||
|
Long plateGoodId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
PlateGoodDO plateGoodDO = setPlateGoodDO(goodValue.get(0)).setId(plateGoodId).setOrganId(organId);
|
||||||
|
plateGoodDOS.add(plateGoodDO);
|
||||||
|
// 板材信息合集,添加生产单id,添加生产单板材设计端商品编码,板材信息写入order_raw_goods
|
||||||
|
Long rawGoodsId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
RawGoodsDO rawGoodsDO = setRawGoodsDO(goodValue.get(0)).setId(rawGoodsId).setOrderId(orderId);
|
||||||
|
rawGoodsDOS.add(rawGoodsDO);
|
||||||
|
Long goodId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
GoodsDO plateDO = setGoodsDO(goodValue.get(0)).setId(goodId).setOrderId(orderId)
|
||||||
|
.setRawGoodsId(rawGoodsId).setGoodsId(plateGoodId);
|
||||||
|
goodsDOS.add(plateDO);
|
||||||
|
// 赋值给板件未对应前order_raw_goods的id
|
||||||
|
for (OrderPlateImportExcelVO reqVO : goodValue) {
|
||||||
|
reqVO.setGoodId(goodId);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else { // 商品编码有的
|
||||||
|
// 判断商品是否存在板材库中
|
||||||
|
PlateGoodDO plateGoodDO = plateGoodMapper.selectOne(PlateGoodDO::getGoodsId, value.get(0).getGoodsId());
|
||||||
|
Long plateGoodId = null;
|
||||||
|
if (plateGoodDO != null) {//存在
|
||||||
|
plateGoodId = plateGoodDO.getId();
|
||||||
|
} else {
|
||||||
|
plateGoodId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
PlateGoodDO plateGoodDONew = setPlateGoodDO(value.get(0)).setId(plateGoodId).setOrganId(organId);
|
||||||
|
plateGoodDOS.add(plateGoodDONew);
|
||||||
|
}
|
||||||
|
// 板材信息合集,添加生产单id,添加生产单板材设计端商品编码,板材信息写入order_raw_goods
|
||||||
|
Long rawGoodsId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
RawGoodsDO rawGoodsDO = setRawGoodsDO(value.get(0)).setId(rawGoodsId).setOrderId(orderId);
|
||||||
|
rawGoodsDOS.add(rawGoodsDO);
|
||||||
|
Long goodId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
GoodsDO plateDO = setGoodsDO(value.get(0)).setId(goodId).setOrderId(orderId)
|
||||||
|
.setRawGoodsId(rawGoodsId).setGoodsId(plateGoodId);
|
||||||
|
goodsDOS.add(plateDO);
|
||||||
|
// 赋值给板件未对应前order_raw_goods的id
|
||||||
|
for (OrderPlateImportExcelVO reqVO : value) {
|
||||||
|
reqVO.setGoodId(goodId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
// 房间名称为条件进行分组
|
||||||
|
Map<String, List<OrderPlateImportExcelVO>> roomCollect = excelVOS.stream().collect(
|
||||||
|
Collectors.groupingBy(
|
||||||
|
excelVO -> excelVO.getRoomsName() != null ? excelVO.getRoomsName() : " ",
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
System.out.println("roomCollect " + roomCollect);
|
||||||
|
|
||||||
|
roomCollect.forEach((roomName, listRoom) -> {
|
||||||
|
Long roomId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
// 柜体名称为条件进行分组
|
||||||
|
Map<String, List<OrderPlateImportExcelVO>> bodyCollect = listRoom.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
excelVO -> excelVO.getCabinetsName() != null ? excelVO.getCabinetsName() : " ",
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
|
||||||
|
bodyCollect.forEach((bodyName, listBody) -> {
|
||||||
|
Long bodyId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
final Double[] plateCountByCabinetName = {0.0};
|
||||||
|
OrderBodyDO orderBodyDO = OrderBodyDO.builder().id(bodyId).orderId(orderId).orderId(organId)
|
||||||
|
.roomId(roomId).roomName(roomName).name(bodyName).width(0.0).height(0.0)
|
||||||
|
.depth(0.0).multiNum(0).plateNum(0).unregularNum(0).filename("").remark("").build(); //没有获取柜体的长宽高
|
||||||
|
|
||||||
|
|
||||||
|
// 加工组类型为条件进行分组
|
||||||
|
Map<String, List<OrderPlateImportExcelVO>> synthesisCollect = listBody.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
excelVO -> excelVO.getSynthesis() != null ? excelVO.getSynthesis() : " ",
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
Long groupTypeId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
|
||||||
|
synthesisCollect.forEach((synthesis, listSynthesis) -> {
|
||||||
|
// 加工组名称为条件进行分组
|
||||||
|
Map<String, List<OrderPlateImportExcelVO>> combinationNameCollect = listSynthesis.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
excelVO -> excelVO.getCombinationName() != null ? excelVO.getCombinationName() : " ",
|
||||||
|
Collectors.toList()
|
||||||
|
));
|
||||||
|
combinationNameCollect.forEach((combinationName, listCombinationName) -> {
|
||||||
|
Long groupId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
// 板数量
|
||||||
|
final Double[] plateCountByCombination = {0.0};
|
||||||
|
OrderGroupDO orderGroupDO = OrderGroupDO.builder().id(groupId).orderId(orderId).orderId(organId).bodyId(bodyId)
|
||||||
|
.groupTypeId(groupTypeId).groupTypeName(synthesis).name(combinationName).width(0.0).height(0.0)
|
||||||
|
.depth(0.0).multiNum(0).plateNum(0).unregularNum(0).filename("").remark("").build();
|
||||||
|
|
||||||
|
listCombinationName.forEach(combination -> {
|
||||||
|
|
||||||
|
if (combination.getGoodType().equals("板材")) {
|
||||||
|
//板材
|
||||||
|
plateCountByCombination[0] = plateCountByCombination[0] + Double.parseDouble(combination.getGoodsNumber());
|
||||||
|
for (int i = 0; i < Integer.parseInt(combination.getGoodsNumber()); i++) {
|
||||||
|
Long plateId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
PlateDO plateDO = PlateDO.builder()
|
||||||
|
.id(plateId).orderId(orderId).name(combination.getName()).plateNo(combination.getPlateNo())
|
||||||
|
.goodsId(combination.getGoodId()).width(BigDecimal.valueOf(Double.parseDouble(combination.getWidth())))
|
||||||
|
.height(BigDecimal.valueOf(Double.parseDouble(combination.getHeight()))).thickness(BigDecimal.valueOf(Double.parseDouble(combination.getThickness())))
|
||||||
|
.splitWidth(BigDecimal.valueOf(Double.parseDouble(combination.getSplitWidth())))
|
||||||
|
.splitHeight(BigDecimal.valueOf(Double.parseDouble(combination.getSplitHeight())))
|
||||||
|
.splitThickness(BigDecimal.valueOf(Double.parseDouble(combination.getThickness())))
|
||||||
|
.sealLeft(BigDecimal.valueOf(Double.parseDouble(combination.getSealLeft())))
|
||||||
|
.sealRight(BigDecimal.valueOf(Double.parseDouble(combination.getSealRight())))
|
||||||
|
.sealUp(BigDecimal.valueOf(Double.parseDouble(combination.getSealUp())))
|
||||||
|
.sealDown(BigDecimal.valueOf(Double.parseDouble(combination.getSealDown())))
|
||||||
|
.holeFace(Integer.valueOf(combination.getTypographicFace()))
|
||||||
|
.texture(Integer.valueOf(combination.getTexture()))
|
||||||
|
.openDoorType(Integer.valueOf(combination.getOpenDoorType()))
|
||||||
|
.isSpecialShaped(false)
|
||||||
|
.isSculpt(false)
|
||||||
|
.remark(combination.remarkJSON())
|
||||||
|
.build();
|
||||||
|
plateDOS.add(plateDO);
|
||||||
|
|
||||||
|
OrderItemDO orderItemDO = OrderItemDO.builder().orderId(orderId).type(1)
|
||||||
|
.roomId(roomId).bodyId(bodyId).plateId(plateId)
|
||||||
|
.num(1.0).groupId(groupId).build();
|
||||||
|
orderItemDOS.add(orderItemDO);
|
||||||
|
orderModelDOS.add(OrderModelDO.builder().orderId(orderId).plateId(plateId).build());
|
||||||
|
}
|
||||||
|
plateCountByCabinetName[0] = plateCountByCabinetName[0] + plateCountByCombination[0];
|
||||||
|
|
||||||
|
} else {
|
||||||
|
//配件
|
||||||
|
Long partsId = (Long) snowFlakeGenerator.nextId(null);
|
||||||
|
OrderPartsDO orderPartsDO = OrderPartsDO.builder().id(partsId).orderId(orderId).goodsId(combination.getGoodsId())
|
||||||
|
.name(combination.getName()).material(combination.getMaterial()).type(combination.getGoodType())
|
||||||
|
.model(combination.getModel()).spec(combination.getSpec()).brand(combination.getBrand()).factory(combination.getFactory())
|
||||||
|
.unit(combination.getUnit()).price(0.0).isComposite(false).remark(combination.remarkJSON()).isComposite(false).build();
|
||||||
|
orderPartsDOS.add(orderPartsDO);
|
||||||
|
OrderItemDO orderItemDO = OrderItemDO.builder().orderId(orderId).type(2)
|
||||||
|
.roomId(roomId).bodyId(bodyId).partsId(partsId).groupId(groupId)
|
||||||
|
.num(Double.valueOf(combination.getGoodsNumber())).build();
|
||||||
|
orderItemDOS.add(orderItemDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
orderGroupDO.setPlateNum(plateCountByCombination[0].intValue());
|
||||||
|
orderGroupDOS.add(orderGroupDO);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
orderBodyDO.setPlateNum(Integer.valueOf(plateCountByCabinetName[0].intValue()));
|
||||||
|
orderBodyDOS.add(orderBodyDO);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
map.put("rawGoodsDOS", rawGoodsDOS);
|
||||||
|
map.put("goodsDOS", goodsDOS);
|
||||||
|
map.put("plateGoodDOS", plateGoodDOS);
|
||||||
|
map.put("orderBodyDOS", orderBodyDOS);
|
||||||
|
map.put("orderGroupDOS", orderGroupDOS);
|
||||||
|
map.put("plateDOS", plateDOS);
|
||||||
|
map.put("orderPartsDOS", orderPartsDOS);
|
||||||
|
map.put("orderItemDOS", orderItemDOS);
|
||||||
|
map.put("orderModuleExtraDOS", orderModuleExtraDOS);
|
||||||
|
map.put("orderModelDOS", orderModelDOS);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 板材库数据
|
||||||
|
private PlateGoodDO setPlateGoodDO(OrderPlateImportExcelVO excelVO) {
|
||||||
|
return PlateGoodDO.builder()
|
||||||
|
// .id(plateGoodId)
|
||||||
|
.goodsId("")
|
||||||
|
.goodsName(excelVO.getGoodsName())
|
||||||
|
.material(excelVO.getMaterial())
|
||||||
|
.color(excelVO.getColor())
|
||||||
|
.texture("")
|
||||||
|
.width(Double.valueOf(excelVO.getWidth()))
|
||||||
|
.height(Double.valueOf(excelVO.getHeight()))
|
||||||
|
.thickness(Double.valueOf(excelVO.getThickness()))
|
||||||
|
.spec(excelVO.getSpec())
|
||||||
|
.brand(excelVO.getBrand())
|
||||||
|
// .organId(organId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// RawGoodsDO数据
|
||||||
|
private RawGoodsDO setRawGoodsDO(OrderPlateImportExcelVO excelVO) {
|
||||||
|
return RawGoodsDO.builder()
|
||||||
|
// .id(rawGoodsId)
|
||||||
|
// .orderId(orderId)
|
||||||
|
.rawGoodsId(excelVO.getGoodsId())
|
||||||
|
.goodsName(excelVO.getGoodsName())
|
||||||
|
.material(excelVO.getMaterial())
|
||||||
|
.color(excelVO.getColor())
|
||||||
|
.thickness(Double.valueOf(excelVO.getThickness()))
|
||||||
|
.spec(excelVO.getSpec())
|
||||||
|
.brand(excelVO.getBrand())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// GoodsDO数据
|
||||||
|
private GoodsDO setGoodsDO(OrderPlateImportExcelVO excelVO) {
|
||||||
|
return GoodsDO.builder()
|
||||||
|
// .id(goodId)
|
||||||
|
// .orderId(orderId)
|
||||||
|
// .rawGoodsId(rawGoodsId)
|
||||||
|
// .goodsId(plateGoodId)
|
||||||
|
.goodsName(excelVO.getGoodsName())
|
||||||
|
.material(excelVO.getMaterial())
|
||||||
|
.color(excelVO.getColor())
|
||||||
|
.width(BigDecimal.valueOf(Double.valueOf(excelVO.getWidth())))
|
||||||
|
.height(BigDecimal.valueOf(Double.valueOf(excelVO.getHeight())))
|
||||||
|
.thickness(BigDecimal.valueOf(Double.valueOf(excelVO.getThickness())))
|
||||||
|
.spec(excelVO.getSpec())
|
||||||
|
.brand(excelVO.getBrand())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
// spec分离数据
|
||||||
|
public List<String> spec(String spec) {
|
||||||
|
List<String> list = null;
|
||||||
|
|
||||||
|
String[] parts = spec.split("\\×");
|
||||||
|
if (parts.length <= 1) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (int i = 0; i < parts.length; i++) {
|
||||||
|
list.add(parts[i]);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 对数据进行分类
|
||||||
|
private HashMap<String, List<OrderPlateImportExcelVO>> classifyGoods(List<OrderPlateImportExcelVO> list) {
|
||||||
|
HashMap<String, List<OrderPlateImportExcelVO>> map = new HashMap<>();
|
||||||
|
List<OrderPlateImportExcelVO> plateLists = new ArrayList<>();
|
||||||
|
List<OrderPlateImportExcelVO> partsLists = new ArrayList<>();
|
||||||
|
for (OrderPlateImportExcelVO detail : list) {
|
||||||
|
//判断是板材还是配件
|
||||||
|
if (detail.getGoodType().equals("板材")) {
|
||||||
|
plateLists.add(detail);
|
||||||
|
} else {
|
||||||
|
partsLists.add(detail);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
map.put("plate", plateLists);
|
||||||
|
map.put("parts", partsLists);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
}
|
||||||
+19
-29
@@ -28,17 +28,19 @@ public class OrderPlateImportExcelVO {
|
|||||||
|
|
||||||
@ExcelProperty(value = "序号")
|
@ExcelProperty(value = "序号")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private int ordinal;
|
private String ordinal;
|
||||||
|
|
||||||
@ExcelProperty(value = "类型", converter = DictConvert.class)
|
@ExcelProperty(value = "类型", converter = DictConvert.class)
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@DictFormat(DictTypeConstants.PRODUCT_TYPE)
|
@DictFormat(DictTypeConstants.PRODUCT_TYPE)
|
||||||
private int goodType;
|
private String goodType;
|
||||||
|
|
||||||
@ExcelProperty(value = "物料编码")
|
@ExcelProperty(value = "物料编码")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private String goodsId;
|
private String goodsId;
|
||||||
|
|
||||||
|
private Long goodId;//商品id
|
||||||
|
|
||||||
@ExcelProperty(value = "商品名称")
|
@ExcelProperty(value = "商品名称")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private String goodsName;
|
private String goodsName;
|
||||||
@@ -74,7 +76,7 @@ public class OrderPlateImportExcelVO {
|
|||||||
@ExcelProperty(value = "数量")
|
@ExcelProperty(value = "数量")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@NotNull
|
@NotNull
|
||||||
private float goodsNumber;
|
private String goodsNumber;
|
||||||
|
|
||||||
@ExcelProperty(value = "房间")
|
@ExcelProperty(value = "房间")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@@ -87,7 +89,7 @@ public class OrderPlateImportExcelVO {
|
|||||||
@ExcelProperty(value = "加工组类型", converter = DictConvert.class)
|
@ExcelProperty(value = "加工组类型", converter = DictConvert.class)
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@DictFormat(DictTypeConstants.SYNTHESIS_TYPE)
|
@DictFormat(DictTypeConstants.SYNTHESIS_TYPE)
|
||||||
private int synthesis;
|
private String synthesis;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
@@ -107,54 +109,54 @@ public class OrderPlateImportExcelVO {
|
|||||||
|
|
||||||
@ExcelProperty(value = "成品长")
|
@ExcelProperty(value = "成品长")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal height;
|
private String height;
|
||||||
|
|
||||||
@ExcelProperty(value = "成品宽")
|
@ExcelProperty(value = "成品宽")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal width;
|
private String width;
|
||||||
|
|
||||||
@ExcelProperty(value = "拆单长")
|
@ExcelProperty(value = "拆单长")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal splitHeight;
|
private String splitHeight;
|
||||||
|
|
||||||
@ExcelProperty(value = "拆单宽")
|
@ExcelProperty(value = "拆单宽")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal splitWidth;
|
private String splitWidth;
|
||||||
|
|
||||||
@ExcelProperty(value = "厚")
|
@ExcelProperty(value = "厚")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal splitThickness;
|
private String thickness;
|
||||||
|
|
||||||
@ExcelProperty(value = "左封边")
|
@ExcelProperty(value = "左封边")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal sealLeft;
|
private String sealLeft;
|
||||||
|
|
||||||
@ExcelProperty(value = "右封边")
|
@ExcelProperty(value = "右封边")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal sealRight;
|
private String sealRight;
|
||||||
|
|
||||||
@ExcelProperty(value = "上封边")
|
@ExcelProperty(value = "上封边")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal sealUp;
|
private String sealUp;
|
||||||
|
|
||||||
@ExcelProperty(value = "下封边")
|
@ExcelProperty(value = "下封边")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
private BigDecimal sealDown;
|
private String sealDown;
|
||||||
|
|
||||||
@ExcelProperty(value = "排版面", converter = DictConvert.class)
|
@ExcelProperty(value = "排版面", converter = DictConvert.class)
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@DictFormat(DictTypeConstants.YPOGRAPHY_TYPE)
|
@DictFormat(DictTypeConstants.TYPOGRAPHY_TYPE)
|
||||||
private int typographicFace;
|
private String typographicFace;
|
||||||
|
|
||||||
@ExcelProperty(value = "纹路", converter = DictConvert.class)
|
@ExcelProperty(value = "纹路", converter = DictConvert.class)
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@DictFormat(DictTypeConstants.GRAIN_TYPE)
|
@DictFormat(DictTypeConstants.GRAIN_TYPE)
|
||||||
private int texture;
|
private String texture;
|
||||||
|
|
||||||
@ExcelProperty(value = "开门方向", converter = DictConvert.class)
|
@ExcelProperty(value = "开门方向", converter = DictConvert.class)
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@DictFormat(DictTypeConstants.DOOR_OPENING_DIRECTIONS)
|
@DictFormat(DictTypeConstants.DOOR_OPENING_DIRECTIONS)
|
||||||
private int openDoorType;
|
private String openDoorType;
|
||||||
|
|
||||||
@ExcelProperty(value = "上传结果")
|
@ExcelProperty(value = "上传结果")
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@@ -194,18 +196,6 @@ public class OrderPlateImportExcelVO {
|
|||||||
@ExcelIgnore
|
@ExcelIgnore
|
||||||
private String remark;
|
private String remark;
|
||||||
|
|
||||||
|
|
||||||
@JsonIgnore
|
|
||||||
public boolean isValidGoods() {
|
|
||||||
return (isNonEmpty(goodsId) ||
|
|
||||||
((isNonEmpty(goodsName)) && (isNonEmpty(model) || isNonEmpty(spec)) && isNonEmpty(material) && isNonEmpty(color) && isNonEmpty(unit)))
|
|
||||||
&& goodsNumber > 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean isNonEmpty(String value) {
|
|
||||||
return value != null && !value.trim().isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
//备注转json数据
|
//备注转json数据
|
||||||
public String remarkJSON() {
|
public String remarkJSON() {
|
||||||
ObjectMapper objectMapper = new ObjectMapper();
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
|||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.cf.imes.module.executor.util.fileConversion.admin.files.excel;
|
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
|
||||||
import com.cf.imes.framework.excel.core.util.ExcelUtils;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @projectName: cf_imes_server
|
|
||||||
* @author: 晨丰科技
|
|
||||||
* @date: 2024/5/14 9:23
|
|
||||||
*/
|
|
||||||
public class Test {
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
String filePath = "C:/Users/Administrator/Desktop/生产单新增Excel模板.xlsx";
|
|
||||||
|
|
||||||
InputStream inputStream = new FileInputStream(filePath);
|
|
||||||
|
|
||||||
ExcelListener<OrderPlateImportExcelVO> excelListener = new ExcelListener();
|
|
||||||
|
|
||||||
|
|
||||||
// ExcelListenerTwo excelListener = new ExcelListenerTwo();
|
|
||||||
|
|
||||||
// List<OrderTest> list = read(inputStream, OrderTest.class,excelListener);
|
|
||||||
|
|
||||||
// System.out.println(list);
|
|
||||||
// EasyExcel.read(inputStream, new ExcelListener()).sheet().doRead();
|
|
||||||
|
|
||||||
|
|
||||||
ExcelReadUtil excelReadUtil = new ExcelReadUtil();
|
|
||||||
|
|
||||||
EasyExcel.read(inputStream, excelListener).sheet().doRead();
|
|
||||||
// excelReadUtil.changeValue(inputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
+6
@@ -1,5 +1,6 @@
|
|||||||
package com.cf.imes.module.system.api.process;
|
package com.cf.imes.module.system.api.process;
|
||||||
|
|
||||||
|
import com.cf.imes.module.system.api.process.dto.ProcessListReqDTO;
|
||||||
import com.cf.imes.module.system.enums.ApiConstants;
|
import com.cf.imes.module.system.enums.ApiConstants;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.Parameter;
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
@@ -20,4 +21,9 @@ public interface ProcessGroupApi {
|
|||||||
@Parameter(name = "groupId", description = "工序组编号", required = true, example = "1024")
|
@Parameter(name = "groupId", description = "工序组编号", required = true, example = "1024")
|
||||||
Boolean getProcessGroup(@RequestParam("groupId") Long groupId);
|
Boolean getProcessGroup(@RequestParam("groupId") Long groupId);
|
||||||
|
|
||||||
|
@GetMapping(PREFIX + "/getGroup")
|
||||||
|
@Operation(summary = "工序组是否存在")
|
||||||
|
@Parameter(name = "groupId", description = "工序组编号", required = true, example = "1024")
|
||||||
|
ProcessListReqDTO getProcessGroupDetail(@RequestParam("groupId") Long groupId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ public interface DictTypeConstants {
|
|||||||
String SMS_SEND_STATUS = "system_sms_send_status"; // 短信发送状态
|
String SMS_SEND_STATUS = "system_sms_send_status"; // 短信发送状态
|
||||||
String SMS_RECEIVE_STATUS = "system_sms_receive_status"; // 短信接收状态
|
String SMS_RECEIVE_STATUS = "system_sms_receive_status"; // 短信接收状态
|
||||||
|
|
||||||
String YPOGRAPHY_TYPE = "ypographyType"; // 排版面
|
String TYPOGRAPHY_TYPE = "typographyType"; // 排版面
|
||||||
String GRAIN_TYPE = "grainType";//纹路类型
|
String GRAIN_TYPE = "grainType";//纹路类型
|
||||||
String DOOR_OPENING_DIRECTIONS = "doorOpeningDirections";//开门方向
|
String DOOR_OPENING_DIRECTIONS = "doorOpeningDirections";//开门方向
|
||||||
String PRODUCT_TYPE = "productType";//产品类型
|
String PRODUCT_TYPE = "productType";//产品类型
|
||||||
|
|||||||
+1
@@ -185,6 +185,7 @@ public interface ErrorCodeConstants {
|
|||||||
|
|
||||||
//=========== 工序组信息 1-002-029-000 ============
|
//=========== 工序组信息 1-002-029-000 ============
|
||||||
ErrorCode PROCESS_GROUP_NOT_EXISTS = new ErrorCode(1_002_029_000, "工序组不存在");
|
ErrorCode PROCESS_GROUP_NOT_EXISTS = new ErrorCode(1_002_029_000, "工序组不存在");
|
||||||
|
ErrorCode PROCESS_GROUP_USED = new ErrorCode(1_002_029_001, "工序组已使用,禁止删除 ");
|
||||||
|
|
||||||
// ========== 机台 1-002-029-000 ==========
|
// ========== 机台 1-002-029-000 ==========
|
||||||
ErrorCode MACHINE_NOT_EXISTS = new ErrorCode(1_002_029_000, "机台不存在");
|
ErrorCode MACHINE_NOT_EXISTS = new ErrorCode(1_002_029_000, "机台不存在");
|
||||||
|
|||||||
@@ -195,6 +195,12 @@
|
|||||||
<groupId>com.github.binarywang</groupId>
|
<groupId>com.github.binarywang</groupId>
|
||||||
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId> <!-- 微信登录(小程序) -->
|
<artifactId>wx-java-miniapp-spring-boot-starter</artifactId> <!-- 微信登录(小程序) -->
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.cf.imes</groupId>
|
||||||
|
<artifactId>cf-module-prod-executor-api</artifactId>
|
||||||
|
<version>2.0.0-jdk8-snapshot</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|||||||
+23
@@ -1,6 +1,12 @@
|
|||||||
package com.cf.imes.module.system.api.process;
|
package com.cf.imes.module.system.api.process;
|
||||||
|
|
||||||
|
import com.cf.imes.framework.common.util.object.BeanUtils;
|
||||||
|
import com.cf.imes.module.system.api.process.dto.ProcessListReqDTO;
|
||||||
|
import com.cf.imes.module.system.api.process.dto.ProcessRespDTO;
|
||||||
|
import com.cf.imes.module.system.dal.dataobject.process.ProcessDO;
|
||||||
|
import com.cf.imes.module.system.dal.dataobject.process.ProcessGroupDO;
|
||||||
import com.cf.imes.module.system.dal.mysql.process.ProcessGroupMapper;
|
import com.cf.imes.module.system.dal.mysql.process.ProcessGroupMapper;
|
||||||
|
import com.cf.imes.module.system.dal.mysql.process.ProcessMapper;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
@@ -16,10 +22,27 @@ public class ProcessGroupApiImpl implements ProcessGroupApi {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProcessGroupMapper processGroupMapper;
|
private ProcessGroupMapper processGroupMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private ProcessMapper processMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Boolean getProcessGroup(Long groupId) {
|
public Boolean getProcessGroup(Long groupId) {
|
||||||
if (processGroupMapper.selectById(groupId) == null)
|
if (processGroupMapper.selectById(groupId) == null)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ProcessListReqDTO getProcessGroupDetail(Long groupId) {
|
||||||
|
ProcessGroupDO processGroupDO = processGroupMapper.selectById(groupId);
|
||||||
|
if (processGroupDO == null)
|
||||||
|
throw exception(PROCESS_GROUP_NOT_EXISTS);
|
||||||
|
String[] items = processGroupDO.getItems().split(",");
|
||||||
|
ProcessListReqDTO processListReqDTO = BeanUtils.toBean(processGroupDO, ProcessListReqDTO.class);
|
||||||
|
for (String item : items) {
|
||||||
|
ProcessDO processDO = processMapper.selectById(Long.parseLong(item));
|
||||||
|
processListReqDTO.getLists().add(BeanUtils.toBean(processDO, ProcessRespDTO.class));
|
||||||
|
}
|
||||||
|
return processListReqDTO;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -1,11 +1,12 @@
|
|||||||
package com.cf.imes.module.system.framework.rpc.config;
|
package com.cf.imes.module.system.framework.rpc.config;
|
||||||
|
|
||||||
|
import com.cf.imes.module.executor.api.orderProcess.OrderProcessApi;
|
||||||
import com.cf.imes.module.infra.api.file.FileApi;
|
import com.cf.imes.module.infra.api.file.FileApi;
|
||||||
import com.cf.imes.module.infra.api.websocket.WebSocketSenderApi;
|
import com.cf.imes.module.infra.api.websocket.WebSocketSenderApi;
|
||||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration(proxyBeanMethods = false)
|
@Configuration(proxyBeanMethods = false)
|
||||||
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class})
|
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, OrderProcessApi.class})
|
||||||
public class RpcConfiguration {
|
public class RpcConfiguration {
|
||||||
}
|
}
|
||||||
|
|||||||
+12
@@ -2,6 +2,7 @@ package com.cf.imes.module.system.service.process;
|
|||||||
|
|
||||||
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import com.cf.imes.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
import com.cf.imes.framework.organ.core.context.OrganContextHolder;
|
||||||
|
import com.cf.imes.module.executor.api.orderProcess.OrderProcessApi;
|
||||||
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSimpleRespVO;
|
import com.cf.imes.module.system.controller.admin.organ.vo.organ.OrganSimpleRespVO;
|
||||||
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupPageReqVO;
|
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupPageReqVO;
|
||||||
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupRespVO;
|
import com.cf.imes.module.system.controller.admin.process.vo.group.ProcessGroupRespVO;
|
||||||
@@ -48,6 +49,9 @@ public class ProcessGroupServiceImpl implements ProcessGroupService {
|
|||||||
@Resource
|
@Resource
|
||||||
private ProcessMapper processMapper;
|
private ProcessMapper processMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrderProcessApi orderProcessApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long createProcessGroup(ProcessGroupSaveReqVO createReqVO) {
|
public Long createProcessGroup(ProcessGroupSaveReqVO createReqVO) {
|
||||||
// 插入
|
// 插入
|
||||||
@@ -78,10 +82,18 @@ public class ProcessGroupServiceImpl implements ProcessGroupService {
|
|||||||
public void deleteProcessGroup(Long id) {
|
public void deleteProcessGroup(Long id) {
|
||||||
// 校验存在
|
// 校验存在
|
||||||
validateProcessGroupExists(id);
|
validateProcessGroupExists(id);
|
||||||
|
// 判断是否在生产中使用这个加工组,如果使用则不能删除
|
||||||
|
// checkProcessGroupUsed(id);
|
||||||
// 删除
|
// 删除
|
||||||
processGroupMapper.deleteById(id);
|
processGroupMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断是否在生产中使用这个加工组
|
||||||
|
private void checkProcessGroupUsed(Long id) {
|
||||||
|
if (orderProcessApi.getOrderProcessByProcessGroupId(id) != null){
|
||||||
|
throw exception(PROCESS_GROUP_USED);
|
||||||
|
}
|
||||||
|
}
|
||||||
private void validateProcessGroupExists(Long id) {
|
private void validateProcessGroupExists(Long id) {
|
||||||
if (processGroupMapper.selectById(id) == null) {
|
if (processGroupMapper.selectById(id) == null) {
|
||||||
throw exception(PROCESS_GROUP_NOT_EXISTS);
|
throw exception(PROCESS_GROUP_NOT_EXISTS);
|
||||||
|
|||||||
+2
-1
@@ -56,6 +56,7 @@ public class GroupServiceImplTest extends BaseDbUnitTest {
|
|||||||
assertPojoEquals(createReqVO, group, "id");
|
assertPojoEquals(createReqVO, group, "id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* @Test
|
/* @Test
|
||||||
public void testUpdateGroup_success() {
|
public void testUpdateGroup_success() {
|
||||||
// mock 数据
|
// mock 数据
|
||||||
@@ -145,6 +146,6 @@ public class GroupServiceImplTest extends BaseDbUnitTest {
|
|||||||
assertEquals(1, pageResult.getTotal());
|
assertEquals(1, pageResult.getTotal());
|
||||||
assertEquals(1, pageResult.getList().size());
|
assertEquals(1, pageResult.getList().size());
|
||||||
assertPojoEquals(dbGroup, pageResult.getList().get(0));
|
assertPojoEquals(dbGroup, pageResult.getList().get(0));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user