parent
820b978ee3
commit
e6c4ee735f
|
|
@ -4,6 +4,7 @@ import java.text.SimpleDateFormat;
|
|||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.as.common.exception.base.BaseException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
|
@ -42,7 +43,7 @@ public class WorkFlowServiceImpl implements WorkFlowService {
|
|||
queryWrapper.eq(workFlowEntity.getWorkPlace() != null, ViewWorkFlowEntity::getWorkPlace, workFlowEntity.getWorkPlace());
|
||||
queryWrapper.eq(workFlowEntity.getPatientName() != null, ViewWorkFlowEntity::getPatientName, workFlowEntity.getPatientName());
|
||||
queryWrapper.eq(workFlowEntity.getStatus() != null, ViewWorkFlowEntity::getStatus, workFlowEntity.getStatus());
|
||||
|
||||
|
||||
queryWrapper.ge(workFlowEntity.getCreatedStartDt() != null, ViewWorkFlowEntity::getCreatedDt, workFlowEntity.getCreatedStartDt()); // 大于等于
|
||||
queryWrapper.le(workFlowEntity.getCreatedEndDt() != null, ViewWorkFlowEntity::getCreatedDt, workFlowEntity.getCreatedEndDt());// 小于等于
|
||||
Page<ViewWorkFlowEntity> page = new Page<>(workFlowEntity.getPageNum(), workFlowEntity.getPageSize());
|
||||
|
|
@ -50,50 +51,52 @@ public class WorkFlowServiceImpl implements WorkFlowService {
|
|||
List<ViewWorkFlowEntity> list = page.getRecords();
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增方法,若没有传过来工单号的情况下需要生成工单号。如果传过来工单号,则需要新增的内容中增加工单的内容
|
||||
* @throws Exception
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Integer addWorkFlow(WorkFlowEntity workFlowEntity) throws Exception{
|
||||
// TODO 需要鉴权,根据操作角色查询本条信息是否应该本角色操作()
|
||||
|
||||
|
||||
if(workFlowEntity.getWorkOrderNo()==null) {
|
||||
workFlowEntity.setWorkOrderNo(makeWorkFlowOrderId());
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return workFlowMapper.insert(workFlowEntity);
|
||||
}
|
||||
|
||||
|
||||
private String makeWorkFlowOrderId() throws Exception{
|
||||
|
||||
|
||||
// 查询id最大的那个订单号 然后截取最后四位,将其转换成数字,然后给这个数字加1
|
||||
QueryWrapper<WorkFlowEntity> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.orderByDesc("sid");
|
||||
Page<WorkFlowEntity> page = new Page<>(1, 1);
|
||||
workFlowMapper.selectPage(page, queryWrapper);
|
||||
List<WorkFlowEntity> list = page.getRecords();
|
||||
String str = "";
|
||||
for (WorkFlowEntity workFlowEntity : list) {
|
||||
str = workFlowEntity.getWorkOrderNo();
|
||||
Page workFlow = workFlowMapper.selectPage(page, queryWrapper);
|
||||
List<WorkFlowEntity> list = workFlow.getRecords();
|
||||
if(list.size()>0) {
|
||||
String str = list.get(0).getWorkOrderNo();
|
||||
// 截取最后四位
|
||||
// 然后返回AS + 当前YYYYmmdd + 刚才的数字
|
||||
String lastFourDigits = str.substring(str.length() - 4);
|
||||
// 转换为整数并加1
|
||||
int number = Integer.parseInt(lastFourDigits) + 1;
|
||||
String formattedNumber = String.format("%04d", number);
|
||||
System.out.println(formattedNumber);
|
||||
|
||||
if (formattedNumber.equals("10000")) {
|
||||
formattedNumber = "0001";
|
||||
}
|
||||
// 获取当前日期并格式化为YYYYmmdd
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
String currentDate = sdf.format(new Date());
|
||||
// 生成最终的字符串
|
||||
String finalString = "AS" + currentDate + formattedNumber;
|
||||
return finalString;
|
||||
}else {
|
||||
throw new BaseException("WorkFlowOrderId_FAILED", "未查询到订单号");
|
||||
}
|
||||
// 然后返回AS + 当前YYYYmmdd + 刚才的数字
|
||||
|
||||
String lastFourDigits = str.substring(str.length() - 4);
|
||||
|
||||
// 转换为整数并加1
|
||||
int number = Integer.parseInt(lastFourDigits) + 1;
|
||||
|
||||
// 获取当前日期并格式化为YYYYmmdd
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
||||
String currentDate = sdf.format(new Date());
|
||||
|
||||
// 生成最终的字符串
|
||||
String finalString = "AS" + currentDate + number;
|
||||
|
||||
|
||||
return finalString;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue