Привет в приведенном ниже коде, используя ниже json ответ на основе времени изменения Я показываю некоторые фильтры, но они не работают.
Моя проблема с измененным временем поиска года и месяца, если это совпадает с моим текущим месяцем и год, затем я показываю количество этапов продаж. с помощью приведенного ниже кода Количество возможностей равно 1, но дает мне 0, оставшееся количество должно быть 0
может ли кто-нибудь помочь мне со следующим сценарием
на основе кода ответа не работает должным образом
неправильный вывод с кодом ниже:
D/monthlist: [2019-12, 2020-1, 2019-12, 2019-12, 2019-12, 2019-12, 2020-1, 2020-1, 2019-12, 2019-12, 2019-12, 2019-12, 2020-1, 2019-12, 2019-12, 2019-12, 2019-12, 2019-12, 2019-12, 2019-12, 2019-12, 2019-12, 2019-12, 2020-1, 2020-1, 2019-12, 2020-1, 2019-12, 2019-12, 2020-1, 2020-7, 2020-1, 2019-12, 2020-1, 2019-12, 2019-12, 2020-1, 2019-12, 2019-9, 2019-9, 2020-5, 2019-9, 2019-9, 2019-9, 2019-9, 2020-1, 2019-9, 2020-1, 2020-1, 2019-12, 2019-8, 2019-8, 2019-8, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-4, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-1, 2020-5, 2020-7, 2020-6, 2020-6, 2020-6, 2020-6, 2020-7, 2020-7, 2020-8]
D/monthyear: 2020-8
D/isModifiedThisMonth: Yes
I/System.out: Count_proposal: 34
D/isModifiedThisMonth: Yes
D/salesstage: Opportunity
I/System.out: Count_negotiation: 13
Count_won: 17
Count_lost: 4
Json ответ:
{
"success":true,
"result":{
"sync":{
"nextSyncToken":1588745221,
"deleted":[
],
"updated":[
{
"blocks":[
{
"label":"Basic Information",
"fields":[
{
"name":"sales_stage",
"value":"Opportunity",
"label":"Sales Stage",
"uitype":"15",
"type":{
"defaultValue":null
}
}
]
},
{
"label":"Opportunity Details",
"fields":[
{
"name":"modifiedtime",
"value":"2020-08-05 13:14:20",
"label":"Modified Time",
"uitype":"70",
"type":{
"defaultValue":null
}
}
]
}
],
"id":"13x30062",
"labelFields":[
"potentialname"
]
}
]
}
}
}
java:
private void workingOnResponseMonthwiseOpportunity(SyncModule syncModule) {
//isdate=true;
String success = syncModule.getSuccess();
if (success.equals("true")) {
SyncResults results = syncModule.getResult();
Sync sync = results.getSync();
ArrayList<SyncUpdated> syncUpdateds = sync.getUpdated();
for (SyncUpdated syncUpdated : syncUpdateds) {
ArrayList<SyncBlocks> syncBlocks = syncUpdated.getBlocks();
String scheduleDates = "";
String scheduleDate = "";
String supportrequired = "";
String winprob = "";
String salesstage = "";
String modality = "";
String modifydatetime = "";
// LocalDateTime modifiedtime= LocalDateTime.parse("");
String date1 = new SimpleDateFormat("dd-MM-yyyy", Locale.getDefault()).format(new Date());
for (SyncBlocks syncBlocks1 : syncBlocks) {
String label = syncBlocks1.getLabel();
if (label.equals("Basic Information")) {
ArrayList<SynFields> synFields = syncBlocks1.getFields();
for (SynFields synFields1 : synFields) {
name = synFields1.getName();
values = synFields1.getValue();
//sales stage
if (name.equals("sales_stage")) {
salesstage = String.valueOf(values);
salesstage_list.add(salesstage);
//support required
}
//modality
else if (name.equals("modality")) {
modality = String.valueOf(values);
modality_list.add(modality);
}
}
} else if (label.equals("Opportunity Details")) {
ArrayList<SynFields> synFields = syncBlocks1.getFields();
for (SynFields synFields1 : synFields) {
String name = synFields1.getName();
values = synFields1.getValue();
if (name.equals("createdtime")) {
scheduleDates = String.valueOf(values);
DateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd");
DateFormat outputFormat = new SimpleDateFormat("dd-MM-yyyy");
DateFormat outputMonth = new SimpleDateFormat("MM");
// String inputDateStr="2013-06-24";
Date date = null;
try {
date = inputFormat.parse(scheduleDates);
scheduleDate = outputMonth.format(date);
} catch (ParseException e) {
e.printStackTrace();
}
} else if (name.equals("cf_996")) {
supportrequired = String.valueOf(values);
supportrequired_list.add(supportrequired);
} else if (name.equals("cf_897")) {
winprob = String.valueOf(values);
winprob_list.add(winprob);
} else if (("modifiedtime".equals(name))) {
modifydatetime = String.valueOf(values);
// Log.d("modifydatetime",modifydatetime);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
modifiedmonth= String.valueOf(LocalDateTime.parse(modifydatetime,format).getMonthValue());
modifiedyear= String.valueOf(LocalDateTime.parse(modifydatetime,format).getYear());
finalmonthyear=modifiedyear.concat("-").concat(modifiedmonth);
// Log.d("finalmonthyear",finalmonthyear);
monthlist.add(finalmonthyear);
// monthlist.add("2020-8");
Log.d("monthlist", String.valueOf(monthlist));
break;
}
}
}
}
PreferenceManagerMyOpportunity.getInstance(requireContext()).setMultipleDataOpportunity(scheduleDate, salesstage, supportrequired, winprob, modality, modifydatetime);
}
MyOpportunityModel opportunityModel = new MyOpportunityModel(scheduleDate, salesstage, supportrequired, winprob, modality, modifydatetime);
//String month = new SimpleDateFormat("MM", Locale.getDefault()).format(new Date());
LocalDate today = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
today = LocalDate.now();
String year = String.valueOf(today.getYear());
String month = String.valueOf(today.getMonthValue());
String monthyear = year.concat("-").concat(month);
// monthyearlist.add(monthyear);
for (String temp : monthlist)
isModifiedThisMonth =(monthyear.contains(temp) ? "Yes" : "No");
Log.d("monthyear", String.valueOf(monthyear));
Log.d("isModifiedThisMonth", String.valueOf(isModifiedThisMonth));
Count_proposal = Collections.frequency(salesstage_list, "Proposal or Price Quote");
System.out.println("Count_proposal: " + Count_proposal);
if (isModifiedThisMonth.equals("Yes")) {
Log.d("isModifiedThisMonth", String.valueOf(isModifiedThisMonth));
//Sales stage starts
Log.d("salesstage", String.valueOf(opportunityModel.getSales_stage()));
boolean issales = false;
for (MyOpportunityModel opportunityModel1 : salesstageSupport) {
if (opportunityModel1.getSales_stage().equals(opportunityModel.getSales_stage())) {
Count_opportunity = Collections.frequency(salesstage_list, "Opportunity");
System.out.println("Count_opportunity: " + Count_opportunity);
issales = true;
}
}
Count_negotiation = Collections.frequency(salesstage_list, "Negotiation or Review");
System.out.println("Count_negotiation: " + Count_negotiation);
Count_won = Collections.frequency(salesstage_list, "Closed Won");
System.out.println("Count_won: " + Count_won);
Count_lost = Collections.frequency(salesstage_list, "Closed Lost");
System.out.println("Count_lost: " + Count_lost);
}