|
|
@ -4,7 +4,10 @@ import java.text.DecimalFormat; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import com.ruoyi.common.core.redis.RedisCache; |
|
|
|
import com.ruoyi.common.utils.DateUtils; |
|
|
|
import com.ruoyi.common.utils.ShiroUtils; |
|
|
|
import com.ruoyi.common.utils.StringUtils; |
|
|
|
import com.ruoyi.system.domain.OutsourceProcess; |
|
|
|
import com.ruoyi.system.mapper.OutsourceProcessMapper; |
|
|
@ -12,6 +15,7 @@ import com.ruoyi.system.service.IOutsourceProcessService; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import com.ruoyi.common.core.text.Convert; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
/** |
|
|
|
* 委外工序Service业务层处理 |
|
|
@ -25,6 +29,9 @@ public class OutsourceProcessServiceImpl implements IOutsourceProcessService |
|
|
|
@Autowired |
|
|
|
private OutsourceProcessMapper outsourceProcessMapper; |
|
|
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
private RedisCache redisCache; |
|
|
|
/** |
|
|
|
* 查询委外工序 |
|
|
|
* |
|
|
@ -55,55 +62,36 @@ public class OutsourceProcessServiceImpl implements IOutsourceProcessService |
|
|
|
return outsourceProcessMapper.selectOutsourceProcessList(outsourceProcess); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 自动生成委外工序编号 |
|
|
|
* |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public String generateOutsourceProcessNo() |
|
|
|
{ |
|
|
|
return redisCache.generateNo("OS"); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 新增委外工序 |
|
|
|
* |
|
|
|
* @param outsourceProcess 委外工序 |
|
|
|
* @return 结果 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
@Override |
|
|
|
public int insertOutsourceProcess(OutsourceProcess outsourceProcess) |
|
|
|
{ |
|
|
|
String loginName = ShiroUtils.getLoginName(); |
|
|
|
String outsourceProcessCode = redisCache.generateNo("WWGX"); |
|
|
|
outsourceProcess.setOutsourceProcessCode(outsourceProcessCode); |
|
|
|
|
|
|
|
//更改日期格式,以提高可读性
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
String dataPart = df.format(new Date()); |
|
|
|
|
|
|
|
//移除日期中的分隔符以便于后续处理
|
|
|
|
String prefix = "WWGX"+dataPart.replace("-",""); |
|
|
|
|
|
|
|
//查询数据库中最大的编号
|
|
|
|
String maxCode = outsourceProcessMapper.findMaxRoundCode(prefix); |
|
|
|
String newCode = generateNewCode(prefix,maxCode); |
|
|
|
|
|
|
|
// outsourceProcess.setOutsourceProcessId();
|
|
|
|
outsourceProcess.setOutsourceProcessCode(newCode); |
|
|
|
System.out.println(outsourceProcess.toString()); |
|
|
|
|
|
|
|
outsourceProcess.setCreateBy(loginName); |
|
|
|
outsourceProcess.setCreateTime(DateUtils.getNowDate()); |
|
|
|
return outsourceProcessMapper.insertOutsourceProcess(outsourceProcess); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
*委外工序ID生产规则 |
|
|
|
*系统自动生成,按照特定编码,编码暂用【ZCGX+年月日+001】, |
|
|
|
*自增长,如:ZCGX20231111001,ZCGX20231111002 |
|
|
|
* |
|
|
|
*/ |
|
|
|
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); |
|
|
|
} |
|
|
|
/** |
|
|
|
* 校验委外工序编号是否唯一 |
|
|
|
* |
|
|
|