|
|
@ -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】, |
|
|
|
*自增长,如:ZCJY20231111001,ZCJY20231111002 |
|
|
|
* |
|
|
|
*/ |
|
|
|
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); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改品质管理制程检验 |
|
|
|
* |
|
|
|