1、日志

2、批量修改工厂
3、转MBOM时,旧的迁移到历史且版本号以B开头
This commit is contained in:
大米 2024-03-06 09:58:38 +08:00
parent 465d760d69
commit 9248214549
13 changed files with 213 additions and 24 deletions

View File

@ -21,7 +21,7 @@ import java.util.TimeZone;
@EnableDiscoveryClient
@EnableScheduling
@EnableFeignClients
@EnableLogRecord(tenant = "com.nflg")
@EnableLogRecord(tenant = "BOM")
public class BomnewApplication {
public static void main(String[] args) {

View File

@ -0,0 +1,50 @@
package com.nflg.product.bomnew.api.user;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.nflg.product.base.core.api.BaseApi;
import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity;
import com.nflg.product.bomnew.pojo.query.BomNewLogQuery;
import com.nflg.product.bomnew.service.BomNewLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import nflg.product.common.vo.ResultVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* t_bom_new_log 表控制层
*
*
* @author makejava
* @since 2024-03-06 08:30:00
*/
@Api(tags = "日志")
@RestController
@RequestMapping("bomNewLogEntity")
public class BomNewLogApi extends BaseApi {
/**
* 服务对象
*/
@Resource
private BomNewLogService bomNewLogService;
/**
* 分页查询所有数据
*
* @param query Query 查询实体
* @return 所有数据
*/
@PostMapping("getListByPage")
@ApiOperation("auto-获取日志")
public ResultVO<IPage<BomNewLogEntity>> selectBomNewLogEntityPageByCondition(@RequestBody BomNewLogQuery query) {
return ResultVO.success(bomNewLogService.getListByPage(query));
}
}

View File

@ -1,8 +1,10 @@
package com.nflg.product.bomnew.mapper.master;
import org.apache.ibatis.annotations.Mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity;
import com.nflg.product.bomnew.pojo.query.BomNewLogQuery;
import org.apache.ibatis.annotations.Param;
/**
* t_bom_new_log 表数据库访问层
@ -12,4 +14,6 @@ import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity;
* @since 2024-03-01 17:10:57
*/
public interface BomNewLogMapper extends BaseMapper<BomNewLogEntity> {
Page<BomNewLogEntity> getListByPage(Page<BomNewLogQuery> page , @Param("query") BomNewLogQuery query);
}

View File

@ -48,6 +48,11 @@ public interface BomNewMbomParentMapper extends BaseMapper<BomNewMbomParentEntit
BomNewMbomMiddleVO getParentById(@Param("rowId") Long rowId );
/**
* 将MBOM迁移到历史表
*/
void insertMBomIntoHistory(@Param("rowId") Long rowId);
}

View File

@ -15,7 +15,7 @@ import java.time.LocalDate;
*
*
* @author makejava
* @since 2024-03-01 17:10:57
* @since 2024-03-06 08:31:13
*/
@Data
@Accessors(chain = true)
@ -31,10 +31,17 @@ public class BomNewLogEntity implements Serializable {
private Long rowId;
/**
* 操作行ID
* 模块名称
*/
@TableField(value = "model_name")
@ApiModelProperty(value = "模块名称")
private String modelName;
/**
* 操作行标识-对应bizNo
*/
@TableField(value = "op_biz_no")
@ApiModelProperty(value = "操作行标识")
@ApiModelProperty(value = "操作行标识-对应bizNo")
private String opBizNo;
/**
@ -78,14 +85,14 @@ public class BomNewLogEntity implements Serializable {
@TableField(value = "op_time")
@ApiModelProperty(value = "操作时间")
private LocalDateTime opTime;
/**
* 部门名称
*/
@TableField(value = "dpt_name")
@ApiModelProperty(value = "部门名称")
private String dptName;
@TableField(value = "dpt_name")
@ApiModelProperty(value = "部门名称")
private String dptName;
private static final long serialVersionUID = -52831510327211450L;
private static final long serialVersionUID = -56481813751074622L;
}

View File

@ -0,0 +1,61 @@
package com.nflg.product.bomnew.pojo.query;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* t_bom_new_log
*
*
* @author makejava
* @since 2024-03-06 08:30:05
*/
@Data
@Accessors(chain = true)
@ApiModel(value="com-nflg-product-bomnew-pojo-new-query-BomNewLogEntityQuery")
public class BomNewLogQuery implements Serializable {
/**
* 模块名称
*/
@ApiModelProperty(value = "模块名称")
private String modelName;
@ApiModelProperty(value = "操作动作")
private String opAction;
@ApiModelProperty(value = "操作人名称")
private String opUserName;
@ApiModelProperty(value = "操作人工号")
private String opUserJobNo;
@ApiModelProperty(value = "操作时间开始时间")
private String startDate;
/**
* 结束操作时间
*/
@ApiModelProperty(value = "操作时间结束时间")
private LocalDateTime endDate;
/**
* 设置每页显示条数
*/
@ApiModelProperty(value = "设置每页显示条数")
private Long pageSize = 20L;
/**
* 当前页
*/
@ApiModelProperty(value = "当前页")
private Long page = 1L;
private static final long serialVersionUID = 1L;
}

View File

@ -1,8 +1,12 @@
package com.nflg.product.bomnew.service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.nflg.product.bomnew.mapper.master.BomNewLogMapper;
import com.nflg.product.bomnew.pojo.entity.BomNewLogEntity;
import com.nflg.product.bomnew.pojo.query.BomNewLogQuery;
import org.springframework.stereotype.Service;
@ -11,9 +15,14 @@ import org.springframework.stereotype.Service;
*
*
* @author makejava
* @since 2024-03-01 17:10:57
* @since 2024-03-06 08:30:03
*/
@Service
public class BomNewLogService extends ServiceImpl<BomNewLogMapper, BomNewLogEntity> {
public IPage<BomNewLogEntity> getListByPage(BomNewLogQuery query){
Page<BomNewLogQuery> page=new Page<>(query.getPage(),query.getPageSize());
return this.getBaseMapper().getListByPage(page,query);
}
}

View File

@ -616,17 +616,18 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
public Boolean saveAllocationFactoryNew(AllocationFactoryParam params) {
VUtils.isTure(CollUtil.isEmpty(params.getData())).throwMessage("分配工厂数据为空");
//按分配的工厂分组
if(BooleanEnum.TRUE.equals(params.getSetSubNode()) ){
if(BooleanEnum.FALSE.equals(params.getSetSubNode()) ){
return saveAllocationFactory(params.getData());
}else {
params.getData().forEach(k->{
try {
List<BomNewPbomParentVO> allBom = this.getAllBomTree(k.getBomRowId());
List<Long> rowIds = allBom.stream().map(u -> u.getRowId()).collect(Collectors.toList());
List<Long> rowIds =new ArrayList<>();
rowIds.add(k.getRowId());
rowIds.addAll(allBom.stream().map(u -> u.getRowId()).collect(Collectors.toList()));
if(CollUtil.isNotEmpty(rowIds)) {
pbomChildService.getBaseMapper().setProductionFactoryCode(k.getProductionFactoryCode(), rowIds);
}
} catch (ExecutionException e) {
e.printStackTrace();
} catch (InterruptedException e) {

View File

@ -77,21 +77,26 @@ public class ConvertToMBomBase {
protected BomNewMbomParentEntity buildMBomParent(String facCode) {
BomNewMbomParentEntity mBomParent = new BomNewMbomParentEntity();
BeanUtil.copyProperties(parent, mBomParent);
BomNewMbomParentEntity oldParent = SpringUtil.getBean(BomNewMbomParentService.class).lambdaQuery().eq(BomNewMbomParentEntity::getMaterialNo, parent.getMaterialNo())
.eq(BomNewMbomParentEntity::getLastVersionIs, 1).eq(BomNewMbomParentEntity::getFacCode, facCode).one();
BomNewMbomParentEntity oldParent = SpringUtil.getBean(BomNewMbomParentService.class).lambdaQuery().eq(BomNewMbomParentEntity::getMaterialNo, parent.getMaterialNo()).eq(BomNewMbomParentEntity::getFacCode, facCode)
.last(" order by current_version desc limit 1").one();
if (Objects.nonNull(oldParent)) {
if (MBomConstantEnum.MBomStatusEnum.PUB_SAP.equalsValue(oldParent.getStatus())) {
//将数据迁移到历史表
SpringUtil.getBean(BomNewMbomParentService.class).getBaseMapper().insertMBomIntoHistory(oldParent.getRowId());
mBomParent.setCurrentVersion(VersionUtil.getNextVersion(oldParent.getCurrentVersion()));
oldParent.setLastVersionIs(0);
this.mBomParentResult.add(oldParent);
mBomParent.setCurrentVersion(VersionUtil.getMBomNextVersion(oldParent.getCurrentVersion()));
SpringUtil.getBean(BomNewMbomDetailService.class).getBaseMapper().deleteByMap(ImmutableMap.of("bom_row_id", oldParent.getRowId()));
SpringUtil.getBean(BomNewMbomParentService.class).getBaseMapper().deleteById(oldParent.getRowId());
// oldParent.setLastVersionIs(0);
// this.mBomParentResult.add(oldParent);
} else {
SpringUtil.getBean(BomNewMbomDetailService.class).getBaseMapper().deleteByMap(ImmutableMap.of("bom_row_id", oldParent.getRowId()));
SpringUtil.getBean(BomNewMbomParentService.class).getBaseMapper().deleteById(oldParent.getRowId());
mBomParent.setCurrentVersion(oldParent.getCurrentVersion());
}
} else {
mBomParent.setCurrentVersion(VersionUtil.getNextVersion(""));
mBomParent.setCurrentVersion(VersionUtil.getMBomNextVersion(""));
}
mBomParent.setRowId(IdWorker.getId());
mBomParent.setFacCode(facCode);

View File

@ -22,6 +22,7 @@ public class DbLogRecordServiceImpl implements ILogRecordService {
BomNewLogEntity logEnt=new BomNewLogEntity();
logEnt.setRowId(IdWorker.getId());
logEnt.setModelName(logRecord.getTenant());
logEnt.setOpBizNo(logRecord.getBizNo());
logEnt.setOpAction(logRecord.getType());
logEnt.setOpContent(logRecord.getAction());

View File

@ -19,6 +19,8 @@ public class VersionUtil {
static final String versionPrefix = "A";
static final String mBomVersionPrefix = "B";
/**
* 获取下一个版本号(大版本)
*/
@ -32,6 +34,15 @@ public class VersionUtil {
}
public static String getMBomNextVersion(String preVersion) {
if (StrUtil.isBlank(preVersion)) {
return mBomVersionPrefix + "00";
}
Integer versionNum = Convert.toInt(StrUtil.replace(preVersion, mBomVersionPrefix, "")) + 1;
return mBomVersionPrefix + StrUtil.padPre(versionNum.toString(), 2, '0');
}
/**
* 获取下一个小版本号(小版本)
*/

View File

@ -6,18 +6,42 @@
<!--@mbg.generated-->
<!--@Table t_bom_new_log -->
<id column="row_id" property="rowId" jdbcType="BIGINT"/>
<result column="op_biz_no" property="opBizNo" jdbcType="BIGINT"/>
<result column="model_name" property="modelName" jdbcType="VARCHAR"/>
<result column="op_biz_no" property="opBizNo" jdbcType="VARCHAR"/>
<result column="op_action" property="opAction" jdbcType="VARCHAR"/>
<result column="op_content" property="opContent" jdbcType="VARCHAR"/>
<result column="op_content_ext" property="opContentExt" jdbcType="VARCHAR"/>
<result column="op_user_job_no" property="opUserJobNo" jdbcType="VARCHAR"/>
<result column="op_user_name" property="opUserName" jdbcType="VARCHAR"/>
<result column="op_time" property="opTime" jdbcType="TIMESTAMP"/>
<result column="dpt_name" property="dptName" jdbcType="VARCHAR" />
<result column="dpt_name" property="dptName" jdbcType="VARCHAR"/>
</resultMap>
<sql id="Base_Column_List">
<!--@mbg.generated-->
row_id, op_biz_no, op_action, op_content, op_content_ext, op_user_job_no, op_user_name, op_time ,dpt_name </sql>
row_id, model_name, op_biz_no, op_action, op_content, op_content_ext, op_user_job_no, op_user_name, op_time, dpt_name </sql>
<sql id="whr">
<if test="query.modelName!=null and query.modelName!=''">
and model_name like concat('%',#{query.modelName},'%')
</if>
<if test="query.opAction!=null and query.opAction!=''">
and op_action like concat('%',#{query.opAction},'%')
</if>
<if test="query.opUserName!=null and query.opUserName!=''">
and op_user_name =#{query.opUserName}
</if>
<if test="query.opUserJobNo!=null and query.opUserJobNo!=''">
and op_user_job_no =#{query.opUserJobNo}
</if>
<if test="query.startDate!=null and query.startDate!=''">
and op_time &gt;= #{query.startDate} and op_time &lt;= #{query.endDate}
</if>
</sql>
<select id="getListByPage" resultType="com.nflg.product.bomnew.pojo.entity.BomNewLogEntity">
select * from t_bom_new_log where 1=1
<include refid="whr"/>
order by op_time desc
</select>
</mapper>

View File

@ -187,5 +187,16 @@
</select>
<!--将MBOM迁移到历史表-->
<insert id="insertMBomIntoHistory">
INSERT INTO `nflg`.`t_bom_new_mbom_parent_history` (`row_id`, `batch_no`, `drawing_no`, `fac_code`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `last_version_is`, `status`, `sysn_sap_user_name`, `sysn_sap_time`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `expire_end_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `order_no`, `modify_time`)
select `row_id`, `batch_no`, `drawing_no`, `fac_code`, `material_no`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `unit_weight`, `total_weight`, `current_version`, `num`, `last_version_is`, `status`, `sysn_sap_user_name`, `sysn_sap_time`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `expire_end_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `order_no`, `modify_time` from t_bom_new_mbom_parent where row_id=#{rowId};
INSERT INTO `nflg`.`t_bom_new_mbom_detail_history` (`row_id`, `bom_row_id`, `parent_row_id`, `drawing_no`, `fac_code`, `material_no`, `current_version`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `unit_weight`, `total_weight`, `num`, `project_type`, `super_material_status`, `virtual_part_is`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `modify_time`, `material_back_status`, `virtual_part_type`)
select `row_id`, `bom_row_id`, `parent_row_id`, `drawing_no`, `fac_code`, `material_no`, `current_version`, `order_number`, `material_name`, `material_desc`, `material_texture`, `material_unit`, `unit_weight`, `total_weight`, `num`, `project_type`, `super_material_status`, `virtual_part_is`, `source_row_id`, `devise_user_code`, `devise_name`, `created_by`, `created_time`, `remark`, `dept_name`, `level_num`, `change_desc`, `notice_nums`, `modify_time`, `material_back_status`, `virtual_part_type` from t_bom_new_mbom_detail where bom_row_id=#{rowId};
</insert>
</mapper>