Modificato servizio getTreeView
This commit is contained in:
@@ -270,7 +270,7 @@ public class ActivityController {
|
||||
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_GET_TREE_VIEW, method = RequestMethod.GET)
|
||||
public ServiceRestResponse getTreeView(HttpServletRequest request,
|
||||
@RequestParam(CommonConstants.PROFILE_DB) String config,
|
||||
@RequestParam() String codJcom,
|
||||
@RequestParam(required = false) String codJcom,
|
||||
@RequestParam(required = false, defaultValue = "false") boolean loadTasks,
|
||||
@RequestParam(required = false) String activityId) throws Exception {
|
||||
|
||||
|
||||
@@ -4,19 +4,42 @@ import it.integry.ems_model.annotation.SqlField;
|
||||
|
||||
public class TreeViewDTO {
|
||||
|
||||
@SqlField("cod_jcom")
|
||||
private String codJcom;
|
||||
|
||||
@SqlField("livello")
|
||||
private int livello;
|
||||
|
||||
@SqlField("activity_id")
|
||||
private String activityId;
|
||||
|
||||
@SqlField("activity_description")
|
||||
private String activityDescription;
|
||||
|
||||
@SqlField("parent_activity_id")
|
||||
private String parentActivityId;
|
||||
|
||||
@SqlField("activity_type_id")
|
||||
private String activityTypeId;
|
||||
|
||||
@SqlField("row")
|
||||
private int row;
|
||||
|
||||
@SqlField("isFinished")
|
||||
private boolean isFinished;
|
||||
|
||||
@SqlField("esito")
|
||||
private String esito;
|
||||
|
||||
public String getCodJcom() {
|
||||
return codJcom;
|
||||
}
|
||||
|
||||
public TreeViewDTO setCodJcom(String codJcom) {
|
||||
this.codJcom = codJcom;
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getRow() {
|
||||
return row;
|
||||
}
|
||||
@@ -70,4 +93,22 @@ public class TreeViewDTO {
|
||||
this.parentActivityId = parentActivityId;
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isFinished() {
|
||||
return isFinished;
|
||||
}
|
||||
|
||||
public TreeViewDTO setFinished(boolean finished) {
|
||||
isFinished = finished;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getEsito() {
|
||||
return esito;
|
||||
}
|
||||
|
||||
public TreeViewDTO setEsito(String esito) {
|
||||
this.esito = esito;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -421,8 +421,8 @@ public class ActivityService {
|
||||
sql =
|
||||
Query.format(
|
||||
"SELECT jtb_rlavr.cod_jflav, jtb_rlavr.data_lav, jtb_rlavr.id_riga, %s as cod_jfas " +
|
||||
" FROM stb_activity INNER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id " +
|
||||
" WHERE parent_activity_id = %s AND stb_activity.cod_jfas <> %s\n" +
|
||||
" FROM stb_activity INNER JOIN jtb_rlavr ON stb_activity.activity_id = jtb_rlavr.activity_id " +
|
||||
" WHERE parent_activity_id = %s AND stb_activity.cod_jfas <> %s\n" +
|
||||
" AND NOT EXISTS(SELECT * from stb_activity_check WHERE stb_activity.cod_jcom = stb_activity_check.cod_jcom AND stb_activity.effective_date between stb_activity_check.data_iniz AND stb_activity_check.data_fine )",
|
||||
codjfas,
|
||||
stbActivity.getActivityId(),
|
||||
@@ -443,7 +443,7 @@ public class ActivityService {
|
||||
|
||||
|
||||
List<JtbRLavt> rapportini = new ArrayList<>();
|
||||
for (Map.Entry<JtbRLavt, List<JtbRLavr>> entry:list ) {
|
||||
for (Map.Entry<JtbRLavt, List<JtbRLavr>> entry : list) {
|
||||
rapportini.add(entry.getKey().setJtbRlavr(entry.getValue()));
|
||||
}
|
||||
|
||||
@@ -512,7 +512,7 @@ public class ActivityService {
|
||||
}
|
||||
|
||||
if (processo.getEffectiveEnddate() != null &&
|
||||
processo.getEffectiveEnddate().before(stbActivity.getEffectiveEnddate())){
|
||||
processo.getEffectiveEnddate().before(stbActivity.getEffectiveEnddate())) {
|
||||
processo.setEffectiveEnddate(EmsRestConstants.DATE_NULL)
|
||||
.setEffectiveEndtime(EmsRestConstants.DATE_NULL)
|
||||
.setActivityResultId("DA COMPLETARE");
|
||||
@@ -537,7 +537,7 @@ public class ActivityService {
|
||||
.setEffectiveTime(stbActivity.getEffectiveTime())
|
||||
.setEffectiveEndtime(stbActivity.getEffectiveEndtime())
|
||||
.setNote(stbActivity.getNote());
|
||||
} catch (Exception e){
|
||||
} catch (Exception e) {
|
||||
multiDBTransactionManager.rollbackAll();
|
||||
throw e;
|
||||
}
|
||||
@@ -948,7 +948,7 @@ public class ActivityService {
|
||||
" INNER JOIN (SELECT *\n" +
|
||||
" FROM jtb_comt\n";
|
||||
|
||||
if (year == null){
|
||||
if (year == null) {
|
||||
sql += " WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA')) jtb_comt\n";
|
||||
} else {
|
||||
sql += " WHERE stato_commessa = 'CHIUSA'\n" +
|
||||
@@ -995,8 +995,13 @@ public class ActivityService {
|
||||
" stb_activity_type.flag_tipologia\n" +
|
||||
" AND stb_activity_type.flag_attiva = 'S'\n" +
|
||||
" GROUP BY srl_activity_type.activity_type_id\n" +
|
||||
" HAVING COUNT(DISTINCT flag_tipologia_next) = 1)\n" +
|
||||
" AND flag_tipologia_next = 'A'))\n" +
|
||||
" HAVING COUNT(DISTINCT flag_tipologia_next) = 1)\n";
|
||||
|
||||
if (activityId == null) {
|
||||
sql += " AND flag_tipologia_next = 'A'\n";
|
||||
}
|
||||
|
||||
sql += " ))\n" +
|
||||
"\n" +
|
||||
"SELECT processi.cod_jcom AS 'Commessa',\n" +
|
||||
" processi.user_name,\n" +
|
||||
@@ -1051,7 +1056,7 @@ public class ActivityService {
|
||||
" task.daPagare as da_pagare,\n" +
|
||||
" task.aCanone as a_canone " +
|
||||
"FROM processi\n" +
|
||||
" LEFT OUTER JOIN sottoattivita ON processi.activity_id = sottoattivita.parent_activity_id\n"+
|
||||
" LEFT OUTER JOIN sottoattivita ON processi.activity_id = sottoattivita.parent_activity_id\n" +
|
||||
" OUTER APPLY ( SELECT CAST(MAX(CASE WHEN task.cod_jfas <> 'C01' THEN 0 ELSE 1 END) AS BIT) AS daPagare,\n" +
|
||||
" CAST(MAX(CASE WHEN task.cod_jfas = 'C01' THEN 0 ELSE 1 END) AS BIT) AS aCanone \n" +
|
||||
" FROM stb_activity task WHERE processi.activity_id = task.parent_activity_id) task ";
|
||||
@@ -1355,7 +1360,29 @@ public class ActivityService {
|
||||
public List<TreeViewDTO> getTreeView(String codJcom, String activityId, boolean loadTasks) throws Exception {
|
||||
String sql;
|
||||
|
||||
if (activityId == null) {
|
||||
if (codJcom == null) {
|
||||
sql = "WITH commesse AS (SELECT cod_jcom FROM jtb_comt WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA'))\n" +
|
||||
"SELECT t.cod_jcom,\n" +
|
||||
" t.livello,\n" +
|
||||
" t.activity_id,\n" +
|
||||
" stb_activity.activity_description,\n" +
|
||||
" t.parent_activity_id,\n" +
|
||||
" stb_activity.activity_type_id,\n" +
|
||||
" count_activity.row,\n" +
|
||||
" CAST(IIF(stb_activity.effective_enddate IS NULL, 1, 0) AS BIT) AS isFinished,\n" +
|
||||
" stb_activity.activity_result_id AS esito\n" +
|
||||
"FROM commesse\n" +
|
||||
" CROSS APPLY [dbo].[getTreeViewActivity](commesse.cod_jcom) t\n" +
|
||||
" INNER JOIN stb_activity ON t.activity_id = stb_activity.activity_id\n" +
|
||||
" OUTER APPLY (SELECT COUNT(*) AS row\n" +
|
||||
" FROM stb_activity s\n" +
|
||||
" WHERE stb_activity.activity_id = s.parent_activity_id) count_activity\n" +
|
||||
"WHERE EXISTS (SELECT *\n" +
|
||||
" FROM srl_activity_type\n" +
|
||||
" WHERE flag_tipologia_next IN ('P', 'A')\n" +
|
||||
" AND srl_activity_type.flag_tipologia = stb_activity.flag_tipologia\n" +
|
||||
" AND srl_activity_type.activity_type_id = stb_activity.activity_type_id)";
|
||||
} else if (activityId == null) {
|
||||
sql = "SELECT t.livello,\n" +
|
||||
" t.activity_id,\n" +
|
||||
" stb_activity.activity_description,\n" +
|
||||
@@ -1372,11 +1399,6 @@ public class ActivityService {
|
||||
"EXISTS (SELECT *\n" +
|
||||
" FROM srl_activity_type\n" +
|
||||
" WHERE flag_tipologia_next IN ('P' " + (loadTasks ? ", 'A'" : "") + ")\n" +
|
||||
"-- AND NOT EXISTS (SELECT *\n" +
|
||||
"-- FROM srl_activity_type tipo_attivita\n" +
|
||||
"-- WHERE tipo_attivita.flag_tipologia_next = 'A'\n" +
|
||||
"-- AND tipo_attivita.activity_type_id = srl_activity_type.activity_type_id\n" +
|
||||
"-- AND tipo_attivita.flag_tipologia = srl_activity_type.flag_tipologia)\n" +
|
||||
" AND srl_activity_type.flag_tipologia = stb_activity.flag_tipologia\n" +
|
||||
" AND srl_activity_type.activity_type_id = stb_activity.activity_type_id)";
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user