|
@@ -1,34 +1,26 @@ |
|
|
package com.ffii.lioner.modules.lioner.client.service; |
|
|
package com.ffii.lioner.modules.lioner.client.service; |
|
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
import java.time.LocalDate; |
|
|
import java.util.ArrayList; |
|
|
|
|
|
import java.util.Date; |
|
|
|
|
|
import java.util.HashMap; |
|
|
|
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
|
import com.ffii.lioner.modules.lioner.client.entity.Client; |
|
|
|
|
|
import com.ffii.lioner.modules.lioner.client.entity.ClientRepository; |
|
|
|
|
|
import com.ffii.lioner.modules.lioner.entity.ImpEvent; |
|
|
|
|
|
import com.ffii.lioner.modules.lioner.client.req.UpdateClientReq; |
|
|
|
|
|
import com.ffii.lioner.modules.common.SecurityUtils; |
|
|
|
|
|
import com.ffii.lioner.modules.common.service.AuditLogService; |
|
|
|
|
|
import com.ffii.lioner.modules.master.entity.SubDivision; |
|
|
|
|
|
import com.ffii.core.exception.UnprocessableEntityException; |
|
|
|
|
|
import com.ffii.core.support.AbstractBaseEntityService; |
|
|
import com.ffii.core.support.AbstractBaseEntityService; |
|
|
import com.ffii.core.support.JdbcDao; |
|
|
import com.ffii.core.support.JdbcDao; |
|
|
import com.ffii.core.utils.BeanUtils; |
|
|
import com.ffii.core.utils.BeanUtils; |
|
|
import com.ffii.core.utils.JsonUtils; |
|
|
|
|
|
|
|
|
|
|
|
import jakarta.persistence.Table; |
|
|
|
|
|
|
|
|
import com.ffii.lioner.modules.common.service.AuditLogService; |
|
|
|
|
|
import com.ffii.lioner.modules.lioner.client.entity.Client; |
|
|
|
|
|
import com.ffii.lioner.modules.lioner.client.entity.ClientRepository; |
|
|
|
|
|
import com.ffii.lioner.modules.lioner.client.req.UpdateClientReq; |
|
|
|
|
|
import com.ffii.lioner.modules.lioner.pdf.service.PdfService; |
|
|
|
|
|
|
|
|
@Service |
|
|
@Service |
|
|
public class ClientService extends AbstractBaseEntityService<Client, Long, ClientRepository> { |
|
|
public class ClientService extends AbstractBaseEntityService<Client, Long, ClientRepository> { |
|
|
|
|
|
|
|
|
private AuditLogService auditLogService; |
|
|
private AuditLogService auditLogService; |
|
|
|
|
|
|
|
|
public ClientService(JdbcDao jdbcDao, ClientRepository repository, AuditLogService auditLogService) { |
|
|
public ClientService(JdbcDao jdbcDao, ClientRepository repository, AuditLogService auditLogService) { |
|
|
super(jdbcDao, repository); |
|
|
super(jdbcDao, repository); |
|
|
this.auditLogService = auditLogService; |
|
|
this.auditLogService = auditLogService; |
|
@@ -131,6 +123,8 @@ public class ClientService extends AbstractBaseEntityService<Client, Long, Clien |
|
|
} |
|
|
} |
|
|
else{ |
|
|
else{ |
|
|
instance = new Client(); |
|
|
instance = new Client(); |
|
|
|
|
|
//default using the current year to get the client code |
|
|
|
|
|
//getNewClientCode(LocalDate.now().getYear()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// List<String> subDivisionNameList = new ArrayList<String>(); |
|
|
// List<String> subDivisionNameList = new ArrayList<String>(); |
|
@@ -1034,5 +1028,20 @@ public class ClientService extends AbstractBaseEntityService<Client, Long, Clien |
|
|
|
|
|
|
|
|
return jdbcDao.queryForInt(sql.toString(), Map.of("name", name)); |
|
|
return jdbcDao.queryForInt(sql.toString(), Map.of("name", name)); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public String getNewClientCode(int year) { |
|
|
|
|
|
String sql = "select " |
|
|
|
|
|
+ " count(1) " |
|
|
|
|
|
+ " from client " |
|
|
|
|
|
//+ " where year(joinDate) = :year " |
|
|
|
|
|
+ " where year(created) = :year " |
|
|
|
|
|
; |
|
|
|
|
|
|
|
|
|
|
|
int idCount = jdbcDao.queryForInt(sql, Map.of("year", year)); |
|
|
|
|
|
String code = year + String.format("%04d", idCount); |
|
|
|
|
|
|
|
|
|
|
|
return code; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |