|
|
@@ -4,7 +4,6 @@ import java.time.LocalDate; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import com.ffii.core.support.AbstractBaseEntityService; |
|
|
@@ -117,14 +116,13 @@ public class ClientService extends AbstractBaseEntityService<Client, Long, Clien |
|
|
|
public Map<String, Object> saveOrUpdate(UpdateClientReq req) { |
|
|
|
Client instance; |
|
|
|
// List<SubDivision> onUsingIdList = new ArrayList<SubDivision>(); |
|
|
|
if(req.getId()>0){ |
|
|
|
if (req.getId() > 0){ |
|
|
|
instance = find(req.getId()).get(); |
|
|
|
// onUsingIdList = this.getSelectedSubDivisionList(req.getId()); |
|
|
|
} |
|
|
|
else{ |
|
|
|
else { |
|
|
|
instance = new Client(); |
|
|
|
//default using the current year to get the client code |
|
|
|
//getNewClientCode(LocalDate.now().getYear()); |
|
|
|
instance.setClientCode(getNewClientCode()); |
|
|
|
} |
|
|
|
|
|
|
|
// List<String> subDivisionNameList = new ArrayList<String>(); |
|
|
@@ -267,7 +265,7 @@ public class ClientService extends AbstractBaseEntityService<Client, Long, Clien |
|
|
|
+ " , phone2 " |
|
|
|
+ " , remarks " |
|
|
|
+ " , created " |
|
|
|
// + " , joinDate " |
|
|
|
+ " , dob " |
|
|
|
+ " , caseManagerId " |
|
|
|
+ " , consultantId " |
|
|
|
+ " FROM client " |
|
|
@@ -303,16 +301,11 @@ public class ClientService extends AbstractBaseEntityService<Client, Long, Clien |
|
|
|
sql.append(" AND email LIKE :email "); |
|
|
|
if (args.containsKey("remarks")) |
|
|
|
sql.append(" AND remarks LIKE :remarks "); |
|
|
|
if (args.containsKey("joinDateFrom")) |
|
|
|
sql.append(" AND joinDate >= :joinDateFrom "); |
|
|
|
if (args.containsKey("joinDateTo")) |
|
|
|
sql.append(" AND joinDate <= :joinDateTo "); |
|
|
|
// if (args.containsKey("type")) |
|
|
|
// sql.append(" AND eventType LIKE :type "); |
|
|
|
// if (args.containsKey("divisionIdList")) |
|
|
|
// sql.append(" AND sd.divisionId IN (:divisionIdList) "); |
|
|
|
// if (args.containsKey("subDivisionIdList")) |
|
|
|
// sql.append(" AND sd.id IN (:subDivisionIdList) "); |
|
|
|
// if (args.containsKey("dobFrom")) |
|
|
|
// sql.append(" AND dob >= :dobFrom "); |
|
|
|
// if (args.containsKey("dobTo")) |
|
|
|
// sql.append(" AND dob <= :dobTo "); |
|
|
|
|
|
|
|
// if (args.containsKey("keyword")){ |
|
|
|
// sql.append(" AND ( createdBy LIKE :keyword "); |
|
|
|
// sql.append(" OR u.username LIKE :keyword "); |
|
|
@@ -1029,12 +1022,13 @@ public class ClientService extends AbstractBaseEntityService<Client, Long, Clien |
|
|
|
return jdbcDao.queryForInt(sql.toString(), Map.of("name", name)); |
|
|
|
} |
|
|
|
|
|
|
|
public String getNewClientCode(int year) { |
|
|
|
public String getNewClientCode() { |
|
|
|
int year = LocalDate.now().getYear(); |
|
|
|
|
|
|
|
String sql = "select " |
|
|
|
+ " count(1) " |
|
|
|
+ " from client " |
|
|
|
//+ " where year(joinDate) = :year " |
|
|
|
+ " where year(created) = :year " |
|
|
|
+ " COUNT(1) " |
|
|
|
+ " FROM client " |
|
|
|
+ " WHERE YEAR(created) = :year " |
|
|
|
; |
|
|
|
|
|
|
|
int idCount = jdbcDao.queryForInt(sql, Map.of("year", year)); |
|
|
|