【用友BOM】更新本地

dev
siontion 3 months ago
parent dbbbb23e38
commit ed36b59e4e

@ -58,6 +58,7 @@ public interface ErrorCodeConstants {
ErrorCode SALARY_USER_NOT_EXISTS = new ErrorCode(1_001_021, "员工工资设置主表不存在");
/*********组织架构************/
ErrorCode WORKSHOP_NOT_EXISTS = new ErrorCode(1_002_001, "车间不存在");
ErrorCode CLASSES_NOT_EXISTS = new ErrorCode(1_002_002, "生产班组不存在");
@ -74,6 +75,7 @@ public interface ErrorCodeConstants {
ErrorCode STORAGE_CHECK_MAT_NOT_EXISTS = new ErrorCode(1_003_008, "盘点物料不存在");
ErrorCode STORAGE_STOCK_QUANTITY_LACK = new ErrorCode(1_003_009, "库存数量不足");
ErrorCode TPLUS_LASTEST_STOCK_NOT_EXISTS = new ErrorCode(1_003_010, "用友Tplus最新库存不存在");
ErrorCode TPLUS_LASTEST_BOM_NOT_EXISTS = new ErrorCode(1_003_011, "用友Tplus最新BOM不存在");
/************订单管理***********/
ErrorCode PROJECT_ORDER_NOT_EXISTS = new ErrorCode(1_004_001, "项目订单不存在");

@ -173,6 +173,13 @@ public class ChanjetController {
}).collect(Collectors.toList());
return success(resultList);
}
@GetMapping("/process-bom/update")
@Operation(summary = "更新bom")
@PreAuthorize("@ss.hasPermission('biz:process-bom:query')")
public CommonResult<Boolean> updateProcessBom() throws ChanjetApiException {
chanjetSchedule.queryProcessBom();
return success(true);
}
@GetMapping("/stock/query")
@Operation(summary = "查询存货")
@ -257,6 +264,8 @@ public class ChanjetController {
// //查询仓库
// chanjetSchedule.queryWarehouse();
//查询bom表
chanjetSchedule.queryProcessBom();
//查询库存-现存量
chanjetSchedule.queryStock();

@ -56,4 +56,7 @@ public class BomMaterialVO {
@Schema(description = "需用数量")
private BigDecimal requiredQuantity;
@Schema(description = "一级产品编码")
private String topCode;
}

@ -0,0 +1,95 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.tpluslastestbom;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.CommonResult;
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
import static com.chanko.yunxi.mes.framework.common.pojo.CommonResult.success;
import com.chanko.yunxi.mes.framework.excel.core.util.ExcelUtils;
import com.chanko.yunxi.mes.framework.operatelog.core.annotations.OperateLog;
import static com.chanko.yunxi.mes.framework.operatelog.core.enums.OperateTypeEnum.*;
import com.chanko.yunxi.mes.module.biz.controller.admin.tpluslastestbom.vo.*;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.tpluslastestbom.TplusLastestBomDO;
import com.chanko.yunxi.mes.module.biz.service.tpluslastestbom.TplusLastestBomService;
@Tag(name = "管理后台 - 用友Tplus最新BOM")
@RestController
@RequestMapping("/biz/tplus-lastest-bom")
@Validated
public class TplusLastestBomController {
@Resource
private TplusLastestBomService tplusLastestBomService;
@PostMapping("/create")
@Operation(summary = "创建用友Tplus最新BOM")
@PreAuthorize("@ss.hasPermission('biz:tplus-lastest-bom:create')")
public CommonResult<Long> createTplusLastestBom(@Valid @RequestBody TplusLastestBomSaveReqVO createReqVO) {
return success(tplusLastestBomService.createTplusLastestBom(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新用友Tplus最新BOM")
@PreAuthorize("@ss.hasPermission('biz:tplus-lastest-bom:update')")
public CommonResult<Boolean> updateTplusLastestBom(@Valid @RequestBody TplusLastestBomSaveReqVO updateReqVO) {
tplusLastestBomService.updateTplusLastestBom(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除用友Tplus最新BOM")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('biz:tplus-lastest-bom:delete')")
public CommonResult<Boolean> deleteTplusLastestBom(@RequestParam("id") Long id) {
tplusLastestBomService.deleteTplusLastestBom(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得用友Tplus最新BOM")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('biz:tplus-lastest-bom:query')")
public CommonResult<TplusLastestBomRespVO> getTplusLastestBom(@RequestParam("id") Long id) {
TplusLastestBomDO tplusLastestBom = tplusLastestBomService.getTplusLastestBom(id);
return success(BeanUtils.toBean(tplusLastestBom, TplusLastestBomRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得用友Tplus最新BOM分页")
@PreAuthorize("@ss.hasPermission('biz:tplus-lastest-bom:query')")
public CommonResult<PageResult<TplusLastestBomRespVO>> getTplusLastestBomPage(@Valid TplusLastestBomPageReqVO pageReqVO) {
PageResult<TplusLastestBomDO> pageResult = tplusLastestBomService.getTplusLastestBomPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, TplusLastestBomRespVO.class));
}
@GetMapping("/export-excel")
@Operation(summary = "导出用友Tplus最新BOM Excel")
@PreAuthorize("@ss.hasPermission('biz:tplus-lastest-bom:export')")
@OperateLog(type = EXPORT)
public void exportTplusLastestBomExcel(@Valid TplusLastestBomPageReqVO pageReqVO,
HttpServletResponse response) throws IOException {
pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<TplusLastestBomDO> list = tplusLastestBomService.getTplusLastestBomPage(pageReqVO).getList();
// 导出 Excel
ExcelUtils.write(response, "用友Tplus最新BOM.xls", "数据", TplusLastestBomRespVO.class,
BeanUtils.toBean(list, TplusLastestBomRespVO.class));
}
}

@ -0,0 +1,74 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.tpluslastestbom.vo;
import lombok.*;
import java.util.*;
import io.swagger.v3.oas.annotations.media.Schema;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.chanko.yunxi.mes.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 用友Tplus最新BOM分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class TplusLastestBomPageReqVO extends PageParam {
@Schema(description = "自增字段,唯一")
private Long id;
@Schema(description = "父级id")
private Long parentId;
@Schema(description = "一级产品编码")
private String topCode;
@Schema(description = "序号")
private Integer sort;
@Schema(description = "层级")
private Integer layer;
@Schema(description = "层次")
private Integer layerSort;
@Schema(description = "物料编码")
private String projectSubCode;
@Schema(description = "物料名称")
private String projectSubName;
@Schema(description = "物料类型")
private String materialType;
@Schema(description = "规格/型号")
private String spec;
@Schema(description = "是否虚拟物料")
private Integer isVirtual;
@Schema(description = "版本号")
private String bomVersion;
@Schema(description = "库存数量")
private BigDecimal stockQuantity;
@Schema(description = "库存单位")
private String unit;
@Schema(description = "物料id")
private Long materialId;
@Schema(description = "生产数量")
private BigDecimal produceQuantity;
@Schema(description = "需用数量")
private BigDecimal requiredQuantity;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

@ -0,0 +1,89 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.tpluslastestbom.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import java.util.*;
import java.math.BigDecimal;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import com.alibaba.excel.annotation.*;
@Schema(description = "管理后台 - 用友Tplus最新BOM Response VO")
@Data
@ExcelIgnoreUnannotated
public class TplusLastestBomRespVO {
@Schema(description = "自增字段,唯一", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("自增字段,唯一")
private Long id;
@Schema(description = "父级id")
@ExcelProperty("父级id")
private Long parentId;
@Schema(description = "一级产品编码")
@ExcelProperty("一级产品编码")
private String topCode;
@Schema(description = "序号")
@ExcelProperty("序号")
private Integer sort;
@Schema(description = "层级")
@ExcelProperty("层级")
private Integer layer;
@Schema(description = "层次")
@ExcelProperty("层次")
private Integer layerSort;
@Schema(description = "物料编码")
@ExcelProperty("物料编码")
private String projectSubCode;
@Schema(description = "物料名称")
@ExcelProperty("物料名称")
private String projectSubName;
@Schema(description = "物料类型")
@ExcelProperty("物料类型")
private String materialType;
@Schema(description = "规格/型号")
@ExcelProperty("规格/型号")
private String spec;
@Schema(description = "是否虚拟物料")
@ExcelProperty("是否虚拟物料")
private Integer isVirtual;
@Schema(description = "版本号")
@ExcelProperty("版本号")
private String bomVersion;
@Schema(description = "库存数量")
@ExcelProperty("库存数量")
private BigDecimal stockQuantity;
@Schema(description = "库存单位")
@ExcelProperty("库存单位")
private String unit;
@Schema(description = "物料id")
@ExcelProperty("物料id")
private Long materialId;
@Schema(description = "生产数量")
@ExcelProperty("生产数量")
private BigDecimal produceQuantity;
@Schema(description = "需用数量")
@ExcelProperty("需用数量")
private BigDecimal requiredQuantity;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

@ -0,0 +1,65 @@
package com.chanko.yunxi.mes.module.biz.controller.admin.tpluslastestbom.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import java.util.*;
import javax.validation.constraints.*;
import java.util.*;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 用友Tplus最新BOM新增/修改 Request VO")
@Data
public class TplusLastestBomSaveReqVO {
@Schema(description = "自增字段,唯一", requiredMode = Schema.RequiredMode.REQUIRED)
private Long id;
@Schema(description = "父级id")
private Long parentId;
@Schema(description = "一级产品编码")
private String topCode;
@Schema(description = "序号")
private Integer sort;
@Schema(description = "层级")
private Integer layer;
@Schema(description = "层次")
private Integer layerSort;
@Schema(description = "物料编码")
private String projectSubCode;
@Schema(description = "物料名称")
private String projectSubName;
@Schema(description = "物料类型")
private String materialType;
@Schema(description = "规格/型号")
private String spec;
@Schema(description = "是否虚拟物料")
private Integer isVirtual;
@Schema(description = "版本号")
private String bomVersion;
@Schema(description = "库存数量")
private BigDecimal stockQuantity;
@Schema(description = "库存单位")
private String unit;
@Schema(description = "物料id")
private Long materialId;
@Schema(description = "生产数量")
private BigDecimal produceQuantity;
@Schema(description = "需用数量")
private BigDecimal requiredQuantity;
}

@ -0,0 +1,98 @@
package com.chanko.yunxi.mes.module.biz.dal.dataobject.tpluslastestbom;
import lombok.*;
import java.util.*;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.chanko.yunxi.mes.framework.mybatis.core.dataobject.BaseDO;
/**
* TplusBOM DO
*
* @author
*/
@TableName("tplus_lastest_bom")
@KeySequence("tplus_lastest_bom_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class TplusLastestBomDO extends BaseDO {
/**
*
*/
@TableId
private Long id;
/**
* id
*/
private Long parentId;
/**
*
*/
private String topCode;
/**
*
*/
private Integer sort;
/**
*
*/
private Integer layer;
/**
*
*/
private Integer layerSort;
/**
*
*/
private String projectSubCode;
/**
*
*/
private String projectSubName;
/**
*
*/
private String materialType;
/**
* /
*/
private String spec;
/**
*
*/
private Integer isVirtual;
/**
*
*/
private String bomVersion;
/**
*
*/
private BigDecimal stockQuantity;
/**
*
*/
private String unit;
/**
* id
*/
private Long materialId;
/**
*
*/
private BigDecimal produceQuantity;
/**
*
*/
private BigDecimal requiredQuantity;
}

@ -47,6 +47,7 @@ public interface ProjectOrderSubMapper extends BaseMapperX<ProjectOrderSubDO> {
return selectList(query);
}
default List<ProjectOrderSubDO> selectListByProjectOrderIdSubNameSpec(Long projectOrderId,String projectSubName,String spec) {
MPJLambdaWrapper<ProjectOrderSubDO> query = new MPJLambdaWrapper<>();
query.selectAll(ProjectOrderSubDO.class)

@ -0,0 +1,43 @@
package com.chanko.yunxi.mes.module.biz.dal.mysql.tpluslastestbom;
import java.util.*;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.chanko.yunxi.mes.framework.mybatis.core.mapper.BaseMapperX;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.tpluslastestbom.TplusLastestBomDO;
import org.apache.ibatis.annotations.Mapper;
import com.chanko.yunxi.mes.module.biz.controller.admin.tpluslastestbom.vo.*;
/**
* TplusBOM Mapper
*
* @author
*/
@Mapper
public interface TplusLastestBomMapper extends BaseMapperX<TplusLastestBomDO> {
default PageResult<TplusLastestBomDO> selectPage(TplusLastestBomPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<TplusLastestBomDO>()
.eqIfPresent(TplusLastestBomDO::getId, reqVO.getId())
.eqIfPresent(TplusLastestBomDO::getParentId, reqVO.getParentId())
.eqIfPresent(TplusLastestBomDO::getTopCode, reqVO.getTopCode())
.eqIfPresent(TplusLastestBomDO::getSort, reqVO.getSort())
.eqIfPresent(TplusLastestBomDO::getLayer, reqVO.getLayer())
.eqIfPresent(TplusLastestBomDO::getLayerSort, reqVO.getLayerSort())
.eqIfPresent(TplusLastestBomDO::getProjectSubCode, reqVO.getProjectSubCode())
.likeIfPresent(TplusLastestBomDO::getProjectSubName, reqVO.getProjectSubName())
.eqIfPresent(TplusLastestBomDO::getMaterialType, reqVO.getMaterialType())
.eqIfPresent(TplusLastestBomDO::getSpec, reqVO.getSpec())
.eqIfPresent(TplusLastestBomDO::getIsVirtual, reqVO.getIsVirtual())
.eqIfPresent(TplusLastestBomDO::getBomVersion, reqVO.getBomVersion())
.eqIfPresent(TplusLastestBomDO::getStockQuantity, reqVO.getStockQuantity())
.eqIfPresent(TplusLastestBomDO::getUnit, reqVO.getUnit())
.eqIfPresent(TplusLastestBomDO::getMaterialId, reqVO.getMaterialId())
.eqIfPresent(TplusLastestBomDO::getProduceQuantity, reqVO.getProduceQuantity())
.eqIfPresent(TplusLastestBomDO::getRequiredQuantity, reqVO.getRequiredQuantity())
.betweenIfPresent(TplusLastestBomDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(TplusLastestBomDO::getId));
}
}

@ -34,6 +34,7 @@ import com.chanko.yunxi.mes.module.biz.dal.dataobject.supplier.SupplierDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.systemparameters.SystemParametersDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.taskdispatch.TaskDispatchDetailDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.taskreport.TaskReportDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.tpluslastestbom.TplusLastestBomDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.tpluslasteststock.TplusLastestStockDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.warehouse.WarehouseDO;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.workshop.WorkshopDO;
@ -47,6 +48,7 @@ import com.chanko.yunxi.mes.module.biz.dal.mysql.supplier.SupplierMapper;
import com.chanko.yunxi.mes.module.biz.dal.mysql.systemparameters.SystemParametersMapper;
import com.chanko.yunxi.mes.module.biz.dal.mysql.taskdispatch.TaskDispatchDetailMapper;
import com.chanko.yunxi.mes.module.biz.dal.mysql.taskreport.TaskReportMapper;
import com.chanko.yunxi.mes.module.biz.dal.mysql.tpluslastestbom.TplusLastestBomMapper;
import com.chanko.yunxi.mes.module.biz.dal.mysql.tpluslasteststock.TplusLastestStockMapper;
import com.chanko.yunxi.mes.module.biz.dal.mysql.warehouse.WarehouseMapper;
import com.chanko.yunxi.mes.module.biz.dal.mysql.workshop.WorkshopMapper;
@ -148,6 +150,11 @@ public class ChanjetSchedule {
@Resource
private TplusLastestStockMapper tplusLastestStockMapper;
private TplusLastestBomMapper tplusLastestBomMapper;
@Resource
private ChanjetManager chanjetManager;
private Boolean getSystemParameters(){
Boolean chanjet_switch = true;
return chanjet_switch;
@ -850,48 +857,33 @@ public class ChanjetSchedule {
/**
* bom
*
* @param materialCode
* @param warehouseId
* @throws ChanjetApiException
*/
@Transactional(rollbackFor = Exception.class)
public List<BomMaterialVO> queryProcessBom(String materialCode, Long warehouseId) throws ChanjetApiException {
public void queryProcessBom() throws ChanjetApiException {
List<BomMaterialVO> resultData = new ArrayList<>(16);
List<ProjectOrderSubDO> projectOrderSubDOS = projectOrderSubMapper.selectList();
List<String> codes = new ArrayList<>();
if(CollUtil.isNotEmpty(projectOrderSubDOS)){
for (ProjectOrderSubDO so : projectOrderSubDOS) {
if(!codes.contains(so.getMaterialCode())) {
List<BomMaterialVO> bomMaterialVOS = chanjetManager.queryProcessBom(so.getMaterialCode(), so.getWarehouseId());
if (!CollUtil.isNotEmpty(bomMaterialVOS)) {
List<BOMChildDTOs> bomDataList = null;
// 设置为“否”,关闭所有与用友通信的接口;为“是”,打开所有与用友通信的接口
if(getSystemParameters()) {
CommonResult<List<QueryBomResVO>> result = chanjetSpi.invokeRetList(QUERY_BOM, new QueryBomReqVO(new QueryBomReqVO.QueryBomDTO(materialCode)), QueryBomResVO.class);
if (!result.isSuccess()) {
throw exception(CALL_API_ERROR);
}
if (CollUtil.isNotEmpty(result.getData())) {
QueryBomResVO topLayer = result.getData().get(0);
bomDataList = topLayer.getBOMChildDTOs();
if (CollUtil.isNotEmpty(bomDataList)) {
for (BOMChildDTOs dto : bomDataList) {
ChildBOM childBOM = dto.getChildBOM();
if (childBOM != null) {
dto.setVersion(childBOM.getVersion())
.setBOMChildDTOs(queryProcessBomById(childBOM.getID()));
}
List<TplusLastestBomDO> insertList = BeanUtils.toBean(bomMaterialVOS, TplusLastestBomDO.class);
insertList.forEach(xo -> {
xo.setId(null).setTopCode(so.getMaterialCode());
});
tplusLastestBomMapper.delete(TplusLastestBomDO::getTopCode, so.getMaterialCode());
tplusLastestBomMapper.insertBatch(insertList);
}
codes.add(so.getMaterialCode());
}
}
}
// 数据包装
if(CollUtil.isNotEmpty(bomDataList)){
for (BOMChildDTOs dto : bomDataList) {
resultData.addAll(getChildrenBomMaterial(2, dto.getBOMChildDTOs(), warehouseId));
dto.setBOMChildDTOs(null); // 避免重复数据
resultData.addAll(getChildrenBomMaterial(1, Arrays.asList(dto), warehouseId));
}
resultData.sort(Comparator.comparing(BomMaterialVO::getSort));
}
return resultData;
}
public List<BomMaterialVO> getChildrenBomMaterial(int layer, List<BOMChildDTOs> childrenBomList, Long warehouseId) throws ChanjetApiException {
@ -1211,7 +1203,6 @@ public class ChanjetSchedule {
/**
*
* @param id
* @throws ChanjetApiException
*/
@Transactional(rollbackFor = Exception.class)

@ -0,0 +1,55 @@
package com.chanko.yunxi.mes.module.biz.service.tpluslastestbom;
import java.util.*;
import javax.validation.*;
import com.chanko.yunxi.mes.module.biz.controller.admin.tpluslastestbom.vo.*;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.tpluslastestbom.TplusLastestBomDO;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
/**
* TplusBOM Service
*
* @author
*/
public interface TplusLastestBomService {
/**
* TplusBOM
*
* @param createReqVO
* @return
*/
Long createTplusLastestBom(@Valid TplusLastestBomSaveReqVO createReqVO);
/**
* TplusBOM
*
* @param updateReqVO
*/
void updateTplusLastestBom(@Valid TplusLastestBomSaveReqVO updateReqVO);
/**
* TplusBOM
*
* @param id
*/
void deleteTplusLastestBom(Long id);
/**
* TplusBOM
*
* @param id
* @return TplusBOM
*/
TplusLastestBomDO getTplusLastestBom(Long id);
/**
* TplusBOM
*
* @param pageReqVO
* @return TplusBOM
*/
PageResult<TplusLastestBomDO> getTplusLastestBomPage(TplusLastestBomPageReqVO pageReqVO);
}

@ -0,0 +1,74 @@
package com.chanko.yunxi.mes.module.biz.service.tpluslastestbom;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.chanko.yunxi.mes.module.biz.controller.admin.tpluslastestbom.vo.*;
import com.chanko.yunxi.mes.module.biz.dal.dataobject.tpluslastestbom.TplusLastestBomDO;
import com.chanko.yunxi.mes.framework.common.pojo.PageResult;
import com.chanko.yunxi.mes.framework.common.pojo.PageParam;
import com.chanko.yunxi.mes.framework.common.util.object.BeanUtils;
import com.chanko.yunxi.mes.module.biz.dal.mysql.tpluslastestbom.TplusLastestBomMapper;
import static com.chanko.yunxi.mes.framework.common.exception.util.ServiceExceptionUtil.exception;
import static com.chanko.yunxi.mes.module.biz.enums.ErrorCodeConstants.*;
/**
* TplusBOM Service
*
* @author
*/
@Service
@Validated
public class TplusLastestBomServiceImpl implements TplusLastestBomService {
@Resource
private TplusLastestBomMapper tplusLastestBomMapper;
@Override
public Long createTplusLastestBom(TplusLastestBomSaveReqVO createReqVO) {
// 插入
TplusLastestBomDO tplusLastestBom = BeanUtils.toBean(createReqVO, TplusLastestBomDO.class);
tplusLastestBomMapper.insert(tplusLastestBom);
// 返回
return tplusLastestBom.getId();
}
@Override
public void updateTplusLastestBom(TplusLastestBomSaveReqVO updateReqVO) {
// 校验存在
validateTplusLastestBomExists(updateReqVO.getId());
// 更新
TplusLastestBomDO updateObj = BeanUtils.toBean(updateReqVO, TplusLastestBomDO.class);
tplusLastestBomMapper.updateById(updateObj);
}
@Override
public void deleteTplusLastestBom(Long id) {
// 校验存在
validateTplusLastestBomExists(id);
// 删除
tplusLastestBomMapper.deleteById(id);
}
private void validateTplusLastestBomExists(Long id) {
if (tplusLastestBomMapper.selectById(id) == null) {
throw exception(TPLUS_LASTEST_BOM_NOT_EXISTS);
}
}
@Override
public TplusLastestBomDO getTplusLastestBom(Long id) {
return tplusLastestBomMapper.selectById(id);
}
@Override
public PageResult<TplusLastestBomDO> getTplusLastestBomPage(TplusLastestBomPageReqVO pageReqVO) {
return tplusLastestBomMapper.selectPage(pageReqVO);
}
}

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chanko.yunxi.mes.module.biz.dal.mysql.tpluslastestbom.TplusLastestBomMapper">
<!--
一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
</mapper>

@ -378,7 +378,7 @@ CREATE TABLE `project_sale_order_packing_clause_detail` (
PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='生产订单包装规则明细表';
drop table if exists `base_salary_month`;
CREATE TABLE `base_salary_month` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
`user_id` bigint(20) DEFAULT NULL COMMENT '员工id',
@ -414,4 +414,55 @@ CREATE TABLE `base_salary_month` (
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='所属年月工资明细表';
) ENGINE=InnoDB COMMENT='所属年月工资明细表';
drop table if exists `tplus_lastest_stock`;
CREATE TABLE `tplus_lastest_stock` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
`WarehouseID` varchar(50) DEFAULT NULL COMMENT '仓库id',
`WarehouseName` varchar(50) DEFAULT NULL COMMENT '仓库名称',
`WarehouseCode` varchar(50) DEFAULT NULL COMMENT '仓库编码',
`InventoryID` varchar(50) DEFAULT NULL COMMENT '物料ID',
`InventoryCode` varchar(50) DEFAULT NULL COMMENT '物料编码',
`InventoryName` varchar(50) DEFAULT NULL COMMENT '物料名称',
`InventoryClassCode` varchar(50) DEFAULT NULL COMMENT '物料类型',
`InventoryClassName` varchar(50) DEFAULT NULL COMMENT '物料类型名称',
`AvailableQuantity` varchar(50) DEFAULT NULL COMMENT '可用量',
`ExistingQuantity` varchar(50) DEFAULT NULL COMMENT '现存量',
PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='用友Tplus最新库存表';
drop table if exists `tplus_lastest_bom`;
CREATE TABLE `tplus_lastest_bom` (
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增字段,唯一',
`parent_id` bigint(20) DEFAULT NULL COMMENT '父级id',
`top_code` varchar(255) DEFAULT NULL COMMENT '一级产品编码',
`sort` int(11) DEFAULT NULL COMMENT '序号',
`layer` int(11) DEFAULT NULL COMMENT '层级',
`layer_sort` int(11) DEFAULT NULL COMMENT '层次',
`project_sub_code` varchar(255) DEFAULT NULL COMMENT '物料编码',
`project_sub_name` varchar(255) DEFAULT NULL COMMENT '物料名称',
`material_type` varchar(255) DEFAULT NULL COMMENT '物料类型',
`spec` varchar(255) DEFAULT NULL COMMENT '规格/型号',
`is_virtual` int(11) DEFAULT NULL COMMENT '是否虚拟物料',
`bom_version` varchar(255) DEFAULT NULL COMMENT '版本号',
`stock_quantity` decimal(10,2) DEFAULT NULL COMMENT '库存数量',
`unit` varchar(255) DEFAULT NULL COMMENT '库存单位',
`material_id` bigint(20) DEFAULT NULL COMMENT '物料id',
`produce_quantity` decimal(10,2) DEFAULT NULL COMMENT '生产数量',
`required_quantity` decimal(10,2) DEFAULT NULL COMMENT '需用数量',
`creator` varchar(64) DEFAULT '' COMMENT '创建者',
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`updater` varchar(64) DEFAULT '' COMMENT '更新者',
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
`tenant_id` bigint(20) NOT NULL DEFAULT '0' COMMENT '租户编号',
PRIMARY KEY (`id`)
) ENGINE=InnoDB COMMENT='用友Tplus最新BOM表';
Loading…
Cancel
Save