Browse Source

[feat]品质管理:

制程检验
新增制程检验制程检验单号根据一定规则自增功能
修改制程工序单号最大值判断条件
dev
liuxiaoxu 7 months ago
parent
commit
60afdf733c
  1. 6
      ruoyi-admin/src/main/java/com/ruoyi/quality/mapper/QualityManufacturingCheckoutMapper.java
  2. 41
      ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityManufacturingCheckoutServiceImpl.java
  3. 2
      ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityManufacturingProcessServiceImpl.java
  4. 4
      ruoyi-admin/src/main/resources/mapper/quality/QualityManufacturingCheckoutMapper.xml

6
ruoyi-admin/src/main/java/com/ruoyi/quality/mapper/QualityManufacturingCheckoutMapper.java

@ -2,6 +2,7 @@ package com.ruoyi.quality.mapper;
import java.util.List;
import com.ruoyi.quality.domain.QualityManufacturingCheckout;
import org.apache.ibatis.annotations.Param;
/**
* 品质管理制程检验Mapper接口
@ -74,4 +75,9 @@ public interface QualityManufacturingCheckoutMapper
* @return 结果
*/
public int restoreQualityManufacturingCheckoutById(Long manufacturingCheckoutId);
/*
* 查询数据库中当前最大的编号
* */
public String findMaxRoundCode(@Param("prefix") String prefix);
}

41
ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityManufacturingCheckoutServiceImpl.java

@ -1,14 +1,21 @@
package com.ruoyi.quality.service.impl;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import com.ruoyi.common.exception.BusinessException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.quality.mapper.QualityManufacturingCheckoutMapper;
import com.ruoyi.quality.domain.QualityManufacturingCheckout;
import com.ruoyi.quality.service.IQualityManufacturingCheckoutService;
import com.ruoyi.common.core.text.Convert;
import org.springframework.transaction.annotation.Transactional;
/**
* 品质管理制程检验Service业务层处理
@ -52,15 +59,49 @@ public class QualityManufacturingCheckoutServiceImpl implements IQualityManufact
* @param qualityManufacturingCheckout 品质管理制程检验
* @return 结果
*/
@Transactional
@Override
public int insertQualityManufacturingCheckout(QualityManufacturingCheckout qualityManufacturingCheckout)
{
//格式化日期格式
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
String formatDate = df.format(new Date());
//去除多余的 - 时间格式转换为yyyyMMdd
String prefix = "ZCJY" +formatDate.replace("-", "");
//查询数据库中当前最大的编号
String maxCode = qualityManufacturingCheckoutMapper.findMaxRoundCode(prefix);
String newCode = generateNewCode(prefix, maxCode);
qualityManufacturingCheckout.setManufacturingCheckoutCode(newCode);
String loginName = ShiroUtils.getLoginName();
qualityManufacturingCheckout.setCreateBy(loginName);
qualityManufacturingCheckout.setCreateTime(DateUtils.getNowDate());
return qualityManufacturingCheckoutMapper.insertQualityManufacturingCheckout(qualityManufacturingCheckout);
}
/**
*制程检验单号生产规则
*系统自动生成按照特定编码编码暂用ZCJY+年月日+001
*自增长:ZCJY20231111001ZCJY20231111002
*
*/
private String generateNewCode(String prefix, String maxCode) {
if (StringUtils.isEmpty(maxCode)){
return prefix + "001";
}
int sequence = Integer.parseInt(maxCode.substring(4)) + 1;
if (sequence > 999){
throw new BusinessException("当日编号已达到最大值999,请检查或调整策略。");
}
//格式化数据
DecimalFormat df = new DecimalFormat("000");
return prefix+df.format(sequence);
}
/**
* 修改品质管理制程检验
*

2
ruoyi-admin/src/main/java/com/ruoyi/quality/service/impl/QualityManufacturingProcessServiceImpl.java

@ -102,7 +102,7 @@ public class QualityManufacturingProcessServiceImpl implements IQualityManufactu
int sequence = Integer.parseInt(maxCode.substring(4)) + 1 ;
//检查序列号是否溢出
if (sequence>9999){
if (sequence > 999){
throw new BusinessException("当日编号已达到最大值999,请检查或调整策略");
}

4
ruoyi-admin/src/main/resources/mapper/quality/QualityManufacturingCheckoutMapper.xml

@ -127,4 +127,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
update quality_manufacturing_checkout set del_flag = '0' where manufacturing_checkout_id = #{manufacturingCheckoutId}
</update>
<select id="findMaxRoundCode" resultType="String">
select max(substring(manufacturing_checkout_code,9)) from quality_manufacturing_checkout where manufacturing_checkout_code like concat(#{prefix},'%')
</select>
</mapper>
Loading…
Cancel
Save