Очень хотелось бы дочерние записи (DictionaryContent ) связать с Dictionary по средствам его UUID идентификатора.
@Entity
public class Dictionary {
@OneToMany(mappedBy = "dictionary")
private List<DictionaryContent> contentList;
}
@Entity
public class DictionaryContent {
@ManyToOne
@JoinColumn(name = "id")
private Dictionary dictionary;
}
однако в таблице DictionaryContent, не появляется никакого идентификатора-указателя на родительский Dictionary.
UPDATE
ОбновляемаяТаблица
SET
ПолеОбновляемойТаблицы1 = Значение1
, ПолеОбновляемойТаблицы2 = Значение2
FROM
ОбновляемаяТаблица
LEFT OUTER JOIN
ДополнительнаяТаблица
ON
ДополнительнаяТаблица.Ключ = ОбновляемаяТаблица.Ключ
WHERE
Условия фильтрации
UPDATE
Account
SET
UsrLastActivityDate = GETDATE()
, UsrProsrochen = 1
FROM
Account account -- Основная обновляемая таблица
LEFT OUTER JOIN
Activity activity -- дополнительная таблица с информацией о задачах
ON
activity.AccountId = account.Id
WHERE
TypeId = '03a75490-53e6-df11-971b-001d60e938c6'
AND DATEDIFF(dd, ModifiedOn ,GETDATE()) > 60
AND activity.Id IS NULL -- аналогичный SELECT фильтр на отсутствие задач
foreach (var newOrder in newOrders)
{
// ищем минимальное количество заявок среди всех менеджеров
var minOrdersCount = managers.Min(m => m.Orders.Count);
// ищем менеджера с найденным количеством (если несколько - берём первого)
var manager = managers.First(m => m.Orders.Count == minOrdersCount);
// даём заявку менее занятому менеджеру
manager.Orders.Add(newOrder);
}
class Manager
{
public string Name { get; private set; }
public List<int> Orders { get; private set; }
public Manager(string name, int ordersCount = 0)
{
Name = name;
Orders = ordersCount > 0
? Enumerable.Range(1, ordersCount).ToList()
: new List<int>();
}
}
static void Main(string[] args)
{
var managers = new Manager[]
{
new Manager("Лена", 1),
new Manager("Оля", 10),
new Manager("Иван", 35),
new Manager("Сергей", 75),
};
var newOrders = Enumerable.Range(1, 35).ToList();
var newOrdersCount = newOrders.Count;
var ordersAssigned = 0;
while (ordersAssigned < newOrdersCount)
{
var ordersCounts = managers.Select(m => m.Orders.Count).OrderBy(count => count).Distinct().ToArray();
var addingOrdersCount = ordersCounts.Length > 1 ? ordersCounts[1] - ordersCounts[0] : ordersCounts.First();
var managersWithMinOrders = managers.Where(m => m.Orders.Count == ordersCounts[0]).ToArray();
// нашли менеджеров с минимальным количеством заявок
if (managersWithMinOrders.Length * addingOrdersCount < newOrdersCount)
{ // заполняем самых незанятых менеджеров до того же уровня занятости
// т.е. добавляем Лене (10 - 1) = 9 заявок
foreach (var manager in managersWithMinOrders)
{
for (int i = 0; i < addingOrdersCount; i++)
{
manager.Orders.Add(newOrders[ordersAssigned]);
ordersAssigned++;
}
}
}
else
{
// незанятых менеджеров нет, заполняем оставшиеся заявки по менеджерам по очереди
while (ordersAssigned < newOrdersCount)
{
var managerIndex = ordersAssigned % managersWithMinOrders.Length;
managersWithMinOrders[managerIndex].Orders.Add(newOrders[ordersAssigned]);
ordersAssigned++;
}
}
}
foreach (var manager in managers)
{
Console.WriteLine("{0}: {1} заявок", manager.Name, manager.Orders.Count);
}
Console.ReadKey();
}
while(iterator.hasNext()){
User item = (User) iterator.next();
//корзина для пользователей с одинаковым кол-вом очков
HashSet<User> bucket = new HashSet<>();
for(int i=0;i<list.size();i++){
User subItem = list.get(i);
if(item.getLeadQualificated() == subItem.getLeadQualificated()){
if(bucket.add(item)){
System.out.println("Добавил в корзину : "+item.getLeadQualificated()+"-> "+item.getManager());
}
}
}
resultMap.put(item.getLeadQualificated(),bucket);//(key-очки, value - список пользователей с таким кол-вом очков)
}
ArrayList<User> list = new ArrayList<>();
list.add(new User("Иванов",2));
list.add(new User("Петров",2));
list.add(new User("Сидоров",5));
list.add(new User("Павлов",5));
list.add(new User("Ромашкин",1));
//Конечный результат
Map<Integer, List<User>> result = list.stream().collect(Collectors.groupingBy(o -> o.scores));
//выводим результат
result.forEach((k,v) -> {
System.out.println("Scores: " + k);
v.forEach(u -> System.out.println(u.name));
});
////
Scores 1
Ромашкин
Scores 2
Иванов
Петров
Scores 5
Сидоров
Павлов
import java.util.Locale;
import java.time.LocalDate;
import java.time.temporal.WeekFields;
import java.time.DayOfWeek;
import static java.time.temporal.TemporalAdjusters.previousOrSame;
import static java.time.temporal.TemporalAdjusters.nextOrSame;
public class Main {
/**
* Determines first and last day of previous, current or following week from
* provided date according to the provided locale.<br/>
* <br/>
* <strong>NOTE</strong>: Although international standard ISO 8601 defines Monday as a first
* day of the week, several countries, including the United States, Canada,
* and Australia consider Sunday as the start of the week, and several other
* countries starts the week from Saturday.
*
* @param fromDate from which date the week offset should be calculated
* @param weekOffset offset in whole weeks, negative - previous, 0 - current, positive - following weeks
* @param locale locale defining which day should be considered a first day of week
* @return array of length 2, containing the dates of the first and last day of the week
*/
private static LocalDate[] getLocalizedWeekBoundary(LocalDate fromDate, long weekOffset, Locale locale) {
LocalDate[] result = new LocalDate[]{null,null};
DayOfWeek localizedFirstDayOfWeek = WeekFields.of(locale).getFirstDayOfWeek();
DayOfWeek localizedLastDayOfWeek = localizedFirstDayOfWeek.plus(6L);
try{
LocalDate shiftedWeekDate = fromDate.plusWeeks(weekOffset);
result[0] = shiftedWeekDate.with(previousOrSame(localizedFirstDayOfWeek));
result[1] = shiftedWeekDate.with(nextOrSame(localizedLastDayOfWeek));
} catch (Exception ex){
// Just add a bit more explanation for the possible RuntimeException,
// which may be thrown if the provided fromDate/weekOffset combination
// cannot be calculated.
throw new IllegalArgumentException(String.format("Shift of provided date by %d week(s) not supported!", weekOffset), ex);
}
return result;
}
public static void main(String[] args) {
for(Locale locale : Locale.getAvailableLocales()){
if(! locale.getDisplayCountry().isEmpty()){
doTest(locale);
}
}
}
private static void doTest(Locale locale){
LocalDate[] boundary;
String separator = Locale.getDefault().equals(locale) ?
"= = = = = = = = = D E F A U L T = = = = = = = ="
: "- - - - - - - - - - - - - - - - - - - - - - - -";
System.out.printf("%n%s%nIn: %s (%s)%nfirst day of week is: %s%n", separator,
locale.getDisplayCountry(), locale, WeekFields.of(locale).getFirstDayOfWeek());
LocalDate fromDate = LocalDate.now();
for (int shift = -1; shift < 2; shift++) {
boundary = getLocalizedWeekBoundary(fromDate, shift, locale);
System.out.printf("Shift %+2d => first: %s - last: %s%n", shift, boundary[0], boundary[1]);
}
}
}
DateTime dt = new DateTime(); // current
DateTime odt = dt.minusDays(7); // past week
DateTime mon = odt.dayOfWeek().setCopy(DateTimeConstants.MONDAY); // get monday of week
DateTime fri = odt.dayOfWeek().setCopy(DateTimeConstants.FRIDAY); // get friday of week
System.out.println(mon);
System.out.println(fri);
System.out.println(mon.getDayOfMonth());
System.out.println(fri.getDayOfMonth());
2018-05-14T14:41:06.072+03:00
2018-05-18T14:41:06.072+03:00
14
18
(function()
{
var src = 'https://cdn.jsdelivr.net/npm/suggestions-jquery@17.12.0/dist/css/suggestions.min.css';
var link = document.createElement('link');
link.setAttribute('src', src);
link.setAttribute('type', 'text/css');
link.setAttribute('rel', 'stylesheet');
document.head.appendChild(link);
src = 'https://cdn.jsdelivr.net/npm/suggestions-jquery@17.12.0/dist/js/jquery.suggestions.min.js';
var scrt = document.createElement('script');
scrt.setAttribute('src', src);
document.head.appendChild(scrt);
}
)();
{
context = this;
setWidth(200px)
logo = new Logo(); //Блок логотипа
menu = new Menu(); //Само меню
addComponent(logo,menu)
}