Skip to content

Commit b5a59e6

Browse files
Version 11.4.0
1 parent 6716590 commit b5a59e6

File tree

231 files changed

+4287
-3173
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

231 files changed

+4287
-3173
lines changed

Src/Android/StyloQ/app/src/main/java/ru/petroglif/styloq/CmdRAttendancePrereqActivity.java

Lines changed: 121 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -13,21 +13,24 @@
1313
import android.view.Window;
1414
import android.widget.Adapter;
1515
import android.widget.AdapterView;
16-
import android.widget.ArrayAdapter;
1716
import android.widget.Button;
1817
import android.widget.ImageView;
1918
import android.widget.LinearLayout;
2019
import android.widget.ListView;
2120
import android.widget.TextView;
21+
2222
import androidx.annotation.IdRes;
2323
import androidx.recyclerview.widget.LinearLayoutManager;
2424
import androidx.recyclerview.widget.RecyclerView;
2525
import androidx.viewpager2.widget.ViewPager2;
26+
2627
import com.google.android.material.tabs.TabLayout;
2728
import com.google.android.material.textfield.TextInputEditText;
29+
2830
import org.json.JSONArray;
2931
import org.json.JSONException;
3032
import org.json.JSONObject;
33+
3134
import java.util.ArrayList;
3235

3336
public class CmdRAttendancePrereqActivity extends SLib.SlActivity {
@@ -51,9 +54,9 @@ private static class AttendanceBlock {
5154
SLib.LDATETIME AttendanceTime; // Выбранное время. null - не выбрано //
5255
CommonPrereqModule.WareEntry Ware;
5356
CommonPrereqModule.ProcessorEntry Prc;
54-
ArrayList <SLib.STimeChunk> BusyList; // Зависит от Prc
55-
ArrayList <SLib.STimeChunk> WorktimeList; // Зависит от Prc
56-
ArrayList <SLib.STimeChunk> CurrentBookingBusyList;
57+
SLib.STimeChunkArray BusyList; // Зависит от Prc
58+
SLib.STimeChunkArray WorktimeList; // Зависит от Prc
59+
SLib.STimeChunkArray CurrentBookingBusyList;
5760
int Duration; // Ожидаемая продолжительность сессии (prcID, goodsID). assert(goodsID || Duration == 0)
5861
//
5962
AttendanceBlock(final Param param)
@@ -269,6 +272,56 @@ private void UpdateBookingView()
269272
}
270273
}
271274
}
275+
private SLib.STimeChunkArray GetBusyListByPrc(CommonPrereqModule.ProcessorEntry prcEntry)
276+
{
277+
SLib.STimeChunkArray result = null;
278+
JSONArray js_busy_list = (prcEntry != null && prcEntry.JsItem != null) ? prcEntry.JsItem.optJSONArray("busy_list") : null;
279+
if(js_busy_list != null && js_busy_list.length() > 0) {
280+
for(int i = 0; i < js_busy_list.length(); i++) {
281+
JSONObject js_item = js_busy_list.optJSONObject(i);
282+
if(js_item != null) {
283+
String low = js_item.optString("low", null);
284+
String upp = js_item.optString("upp", null);
285+
if(SLib.GetLen(low) > 0 && SLib.GetLen(upp) > 0) {
286+
SLib.STimeChunk tc = new SLib.STimeChunk();
287+
tc.Start = SLib.strtodatetime(low, SLib.DATF_ISO8601, SLib.TIMF_HMS);
288+
tc.Finish = SLib.strtodatetime(upp, SLib.DATF_ISO8601, SLib.TIMF_HMS);
289+
if(tc.Start != null && tc.Finish != null) {
290+
if(result == null)
291+
result = new SLib.STimeChunkArray();
292+
result.add(tc);
293+
}
294+
}
295+
}
296+
}
297+
}
298+
return result;
299+
}
300+
private SLib.STimeChunkArray GetWorktimeListByPrc(CommonPrereqModule.ProcessorEntry prcEntry)
301+
{
302+
SLib.STimeChunkArray result = null;
303+
JSONArray js_worktime_list = (prcEntry != null && prcEntry.JsItem != null) ? prcEntry.JsItem.optJSONArray("worktime") : null;
304+
if(js_worktime_list != null && js_worktime_list.length() > 0) {
305+
for(int i = 0; i < js_worktime_list.length(); i++) {
306+
JSONObject js_item = js_worktime_list.optJSONObject(i);
307+
if(js_item != null) {
308+
String low = js_item.optString("low", null);
309+
String upp = js_item.optString("upp", null);
310+
if(SLib.GetLen(low) > 0 && SLib.GetLen(upp) > 0) {
311+
SLib.STimeChunk tc = new SLib.STimeChunk();
312+
tc.Start = SLib.strtodatetime(low, SLib.DATF_ISO8601, SLib.TIMF_HMS);
313+
tc.Finish = SLib.strtodatetime(upp, SLib.DATF_ISO8601, SLib.TIMF_HMS);
314+
if(tc.Start != null && tc.Finish != null) {
315+
if(result == null)
316+
result = new SLib.STimeChunkArray();
317+
result.add(tc);
318+
}
319+
}
320+
}
321+
}
322+
}
323+
return result;
324+
}
272325
private void SetCurrentAttendancePrc(CommonPrereqModule.ProcessorEntry entry)
273326
{
274327
if(entry != null) {
@@ -277,49 +330,8 @@ private void SetCurrentAttendancePrc(CommonPrereqModule.ProcessorEntry entry)
277330
AttdcBlk.Prc = entry;
278331
int prc_id = AttdcBlk.GetPrcID();
279332
if(prc_id > 0) {
280-
AttdcBlk.BusyList = null;
281-
AttdcBlk.WorktimeList = null;
282-
JSONArray js_busy_list = AttdcBlk.Prc.JsItem.optJSONArray("busy_list");
283-
if(js_busy_list != null && js_busy_list.length() > 0) {
284-
for(int i = 0; i < js_busy_list.length(); i++) {
285-
JSONObject js_item = js_busy_list.optJSONObject(i);
286-
if(js_item != null) {
287-
String low = js_item.optString("low", null);
288-
String upp = js_item.optString("upp", null);
289-
if(SLib.GetLen(low) > 0 && SLib.GetLen(upp) > 0) {
290-
SLib.STimeChunk tc = new SLib.STimeChunk();
291-
tc.Start = SLib.strtodatetime(low, SLib.DATF_ISO8601, SLib.TIMF_HMS);
292-
tc.Finish = SLib.strtodatetime(upp, SLib.DATF_ISO8601, SLib.TIMF_HMS);
293-
if(tc.Start != null && tc.Finish != null) {
294-
if(AttdcBlk.BusyList == null)
295-
AttdcBlk.BusyList = new ArrayList<SLib.STimeChunk>();
296-
AttdcBlk.BusyList.add(tc);
297-
}
298-
}
299-
}
300-
}
301-
}
302-
//
303-
JSONArray js_worktime_list = AttdcBlk.Prc.JsItem.optJSONArray("worktime");
304-
if(js_worktime_list != null && js_worktime_list.length() > 0) {
305-
for(int i = 0; i < js_worktime_list.length(); i++) {
306-
JSONObject js_item = js_worktime_list.optJSONObject(i);
307-
if(js_item != null) {
308-
String low = js_item.optString("low", null);
309-
String upp = js_item.optString("upp", null);
310-
if(SLib.GetLen(low) > 0 && SLib.GetLen(upp) > 0) {
311-
SLib.STimeChunk tc = new SLib.STimeChunk();
312-
tc.Start = SLib.strtodatetime(low, SLib.DATF_ISO8601, SLib.TIMF_HMS);
313-
tc.Finish = SLib.strtodatetime(upp, SLib.DATF_ISO8601, SLib.TIMF_HMS);
314-
if(tc.Start != null && tc.Finish != null) {
315-
if(AttdcBlk.WorktimeList == null)
316-
AttdcBlk.WorktimeList = new ArrayList<SLib.STimeChunk>();
317-
AttdcBlk.WorktimeList.add(tc);
318-
}
319-
}
320-
}
321-
}
322-
}
333+
AttdcBlk.BusyList = GetBusyListByPrc(AttdcBlk.Prc);
334+
AttdcBlk.WorktimeList = GetWorktimeListByPrc(AttdcBlk.Prc);
323335
AttdcBlk.SetSelectionDate(AttdcBlk.GetSelectionDate()); // Пересчитывам календарь в соответствии с процессором
324336
AttdcBlk.CurrentBookingBusyList = CPM.GetCurrentDocumentBusyList(prc_id);
325337
}
@@ -335,6 +347,7 @@ else if(AttdcBlk != null) {
335347
AttdcBlk.Duration = CPM.GetServiceDurationForPrc(0, AttdcBlk.GetGoodsID());
336348
}
337349
UpdateAttendanceView();
350+
NotifyTabContentChanged(CommonPrereqModule.Tab.tabProcessors, R.id.attendancePrereqProcessorListView);
338351
}
339352
private void SetCurrentAttendanceWare(CommonPrereqModule.WareEntry entry)
340353
{
@@ -346,9 +359,37 @@ private void SetCurrentAttendanceWare(CommonPrereqModule.WareEntry entry)
346359
else if(AttdcBlk != null) {
347360
AttdcBlk.Ware = null;
348361
}
349-
if(AttdcBlk != null)
350-
AttdcBlk.Duration = CPM.GetServiceDurationForPrc(AttdcBlk.GetPrcID(), AttdcBlk.GetGoodsID());
362+
if(AttdcBlk != null) {
363+
final int prc_id = AttdcBlk.GetPrcID();
364+
final int goods_id = AttdcBlk.GetGoodsID();
365+
if(prc_id == 0 && goods_id > 0) {
366+
SLib.STimeChunkArray united_worktime_list = null;
367+
SLib.STimeChunkArray intersected_busy_list = null;
368+
ArrayList <CommonPrereqModule.ProcessorEntry> prc_list = CPM.GetProcessorListByGoods(goods_id);
369+
if(prc_list != null) {
370+
for(int prcidx = 0; prcidx < prc_list.size(); prcidx++) {
371+
final CommonPrereqModule.ProcessorEntry prc_entry = prc_list.get(prcidx);
372+
SLib.STimeChunkArray wtlist = GetWorktimeListByPrc(prc_entry);
373+
SLib.STimeChunkArray busy_list = GetBusyListByPrc(prc_entry);
374+
if(wtlist != null) {
375+
united_worktime_list = wtlist.Union(united_worktime_list);
376+
}
377+
if(busy_list != null) {
378+
if(intersected_busy_list == null)
379+
intersected_busy_list = busy_list;
380+
else
381+
intersected_busy_list = busy_list.Intersect(intersected_busy_list);
382+
}
383+
}
384+
}
385+
AttdcBlk.BusyList = intersected_busy_list;
386+
AttdcBlk.WorktimeList = united_worktime_list;
387+
AttdcBlk.SetSelectionDate(AttdcBlk.GetSelectionDate()); // Пересчитывам календарь в соответствии с товаром
388+
}
389+
AttdcBlk.Duration = CPM.GetServiceDurationForPrc(prc_id, goods_id);
390+
}
351391
UpdateAttendanceView();
392+
NotifyTabContentChanged(CommonPrereqModule.Tab.tabGoods, R.id.attendancePrereqGoodsListView);
352393
}
353394
private void CreateTabList(boolean force)
354395
{
@@ -505,28 +546,40 @@ private void GotoTab(CommonPrereqModule.Tab tab, @IdRes int recyclerViewToUpdate
505546
}
506547
}
507548
}
508-
private void SetListBackground(View iv, SLib.RecyclerListAdapter a, int itemIdxToDraw, int objType, int objID)
549+
private void SetListBackground(View iv, SLib.RecyclerListAdapter adapter, int itemIdxToDraw, int objType, int objID)
509550
{
510551
int shaperc = 0;
511-
if(GetRecyclerListFocusedIndex(a) == itemIdxToDraw)
552+
if(GetRecyclerListFocusedIndex(adapter) == itemIdxToDraw)
512553
shaperc = R.drawable.shape_listitem_focused;
513554
else {
514555
boolean is_catched = false;
515-
if(objID > 0 && !CPM.IsCurrentDocumentEmpty()) {
516-
final Document _doc = CPM.GetCurrentDocument();
517-
if(objType == SLib.PPOBJ_PERSON && objID == _doc.H.ClientID) {
518-
is_catched = true;
519-
}
520-
else if(objType == SLib.PPOBJ_LOCATION && objID == _doc.H.DlvrLocID) {
521-
is_catched = true;
522-
}
523-
else if(objType == SLib.PPOBJ_GOODS) {
524-
if(CPM.HasGoodsInCurrentOrder(objID))
556+
if(objID > 0) {
557+
if(!CPM.IsCurrentDocumentEmpty()) {
558+
final Document _doc = CPM.GetCurrentDocument();
559+
if(objType == SLib.PPOBJ_PERSON && objID == _doc.H.ClientID) {
525560
is_catched = true;
526-
}
527-
else if(objType == SLib.PPOBJ_PROCESSOR) {
528-
if(CPM.HasPrcInCurrentOrder(objID))
561+
}
562+
else if(objType == SLib.PPOBJ_LOCATION && objID == _doc.H.DlvrLocID) {
529563
is_catched = true;
564+
}
565+
else if(objType == SLib.PPOBJ_GOODS) {
566+
if(CPM.HasGoodsInCurrentOrder(objID))
567+
is_catched = true;
568+
}
569+
else if(objType == SLib.PPOBJ_PROCESSOR) {
570+
if(CPM.HasPrcInCurrentOrder(objID))
571+
is_catched = true;
572+
}
573+
}
574+
if(!is_catched && AttdcBlk != null) {
575+
if(objType == SLib.PPOBJ_PROCESSOR) {
576+
if(AttdcBlk.GetPrcID() == objID)
577+
is_catched = true;
578+
}
579+
else if(objType == SLib.PPOBJ_GOODS) {
580+
if(AttdcBlk.GetGoodsID() == objID)
581+
is_catched = true;
582+
}
530583
}
531584
}
532585
if(is_catched)
@@ -539,13 +592,11 @@ else if(CPM.IsObjInSearchResult(objType, objID))
539592
if(shaperc != 0)
540593
iv.setBackground(getResources().getDrawable(shaperc, getTheme()));
541594
}
542-
private static class PrcByGoodsListAdapter extends ArrayAdapter {
543-
private int RcId;
595+
private static class PrcByGoodsListAdapter extends SLib.InternalArrayAdapter {
544596
private int GoodsID;
545597
PrcByGoodsListAdapter(Context ctx, int rcId, int goodsID, ArrayList data)
546598
{
547599
super(ctx, rcId, data);
548-
RcId = rcId;
549600
GoodsID = goodsID;
550601
}
551602
int GetGoodsID() { return GoodsID; }
@@ -572,13 +623,11 @@ private static class PrcByGoodsListAdapter extends ArrayAdapter {
572623
return convertView; // Return the completed view to render on screen
573624
}
574625
}
575-
private static class GoodsByPrcListAdapter extends ArrayAdapter {
576-
private int RcId;
626+
private static class GoodsByPrcListAdapter extends SLib.InternalArrayAdapter {
577627
private int PrcID;
578628
GoodsByPrcListAdapter(Context ctx, int rcId, int prcID, ArrayList data)
579629
{
580630
super(ctx, rcId, data);
581-
RcId = rcId;
582631
PrcID = prcID;
583632
}
584633
int GetPrcID() { return PrcID; }
@@ -991,7 +1040,7 @@ else if(a.GetListRcId() == R.id.attendancePrereqAttendanceView) {
9911040
}
9921041
boolean busy_hour = false;
9931042
boolean busy_hour_cur = false;
994-
if(AttdcBlk.Prc != null && ((AttdcBlk.BusyList != null && AttdcBlk.BusyList.size() > 0) ||
1043+
if(/*AttdcBlk.Prc != null &&*/((AttdcBlk.BusyList != null && AttdcBlk.BusyList.size() > 0) ||
9951044
AttdcBlk.CurrentBookingBusyList != null && AttdcBlk.CurrentBookingBusyList.size() > 0)) {
9961045
SLib.LDATETIME end_dtm = new SLib.LDATETIME(dt, new SLib.LTIME(hour, 59, 59, 990));
9971046
SLib.STimeChunk cell = new SLib.STimeChunk(new SLib.LDATETIME(dt, new SLib.LTIME(hour, 0, 0, 100)), end_dtm);
@@ -1723,7 +1772,7 @@ else if(goods_id <= 0) {
17231772
bk_item.EstimatedDurationSec = 3600; // default value
17241773
bk_item.Set.Qtty = 1;
17251774
bk_item.Set.Price = CPM.GetPriceForPrc(bk_item.PrcID, bk_item.GoodsID);
1726-
ArrayList <SLib.STimeChunk> new_busy_list = CPM.PutBookingItemToCurrentDocument(bk_item);
1775+
SLib.STimeChunkArray new_busy_list = CPM.PutBookingItemToCurrentDocument(bk_item);
17271776
if(new_busy_list != null) {
17281777
AttdcBlk.CurrentBookingBusyList = new_busy_list;
17291778
UpdateAttendanceView();

Src/Android/StyloQ/app/src/main/java/ru/petroglif/styloq/CommonPrereqModule.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -277,9 +277,9 @@ protected boolean AddTransferItemToCurrentDocument(Document.TransferItem item)
277277
}
278278
return result;
279279
}
280-
protected ArrayList <SLib.STimeChunk> PutBookingItemToCurrentDocument(Document.BookingItem item)
280+
protected SLib.STimeChunkArray PutBookingItemToCurrentDocument(Document.BookingItem item)
281281
{
282-
ArrayList <SLib.STimeChunk> result = null;
282+
SLib.STimeChunkArray result = null;
283283
try {
284284
if(item != null) {
285285
InitCurrenDocument(SLib.sqbdtSvcReq);
@@ -339,17 +339,17 @@ else if(CurrentOrder.H.ClientID == cliID) {
339339
}
340340
return result;
341341
}
342-
public ArrayList <SLib.STimeChunk> GetCurrentDocumentBusyList(int prcID)
342+
public SLib.STimeChunkArray GetCurrentDocumentBusyList(int prcID)
343343
{
344-
ArrayList <SLib.STimeChunk> result = null;
344+
SLib.STimeChunkArray result = null;
345345
if(prcID > 0 && CurrentOrder != null && CurrentOrder.BkList != null && CurrentOrder.BkList.size() > 0) {
346346
for(int i = 0; i < CurrentOrder.BkList.size(); i++) {
347347
Document.BookingItem bi = CurrentOrder.BkList.get(i);
348348
if(bi != null && bi.PrcID == prcID) {
349349
SLib.STimeChunk tc = bi.GetEsimatedTimeChunk();
350350
if(tc != null) {
351351
if(result == null)
352-
result = new ArrayList<SLib.STimeChunk>();
352+
result = new SLib.STimeChunkArray();
353353
result.add(tc);
354354
}
355355
}

0 commit comments

Comments
 (0)