Modifiche per Task
All checks were successful
IntegryManagementSystem_Multi/pipeline/head This commit looks good

This commit is contained in:
2025-02-07 17:56:29 +01:00
parent c14de9c68d
commit 54acb98afa
7 changed files with 113 additions and 30 deletions

View File

@@ -288,7 +288,7 @@ public class EmsRestConstants {
public static final String PATH_ACTIVITY_GET_TYPE_TASK = PATH + "activity/getActivityTypeTask";
public static final String PATH_ACTIVITY_GET_FILE = PATH + "activity/getActivityFile";
public static final String PATH_ACTIVITY_PRODUCTS = PATH + "activity/getProducts";
public static final String PATH_ACTIVITY_COMMESSA = PATH + "activity/getCommessa";
public static final String PATH_ACTIVITY_COMMESSE = PATH + "activity/getCommesse";
public static final String PATH_ACTIVITY_INS_OR_UPDATE = PATH + "activity/insertOrUpdate";
public static final String PATH_ACTIVITY_UPDATE_TASK = PATH + "activity/updateActivityTask";
public static final String PATH_ACTIVITY_GET_ALL_ACTIVITIES_BY_ACTIVE_CUSTOMERS = PATH + "activity/getAllActivitiesByActiveCustomers";

View File

@@ -165,7 +165,8 @@ public class WtbUserDeviceToken extends EntityBase {
WINGEST(2),
WINACT(3),
ORDIFY(4),
WINCLOCK(5);
WINCLOCK(5),
TASK(6);
private final int value;

View File

@@ -33,7 +33,6 @@ then
boolean existSubActivity = UtilityDB.executeSimpleQueryOnlyFirstRowFirstColumn(conn, sql);
StbActivity parent = new StbActivity()
.setActivityId($stbActivity.getParentActivityId())
.setNote("CIAO")
.setActivityResultId(existSubActivity?null:EmsRestConstants.NULL);
parent.setOperation(OperationType.UPDATE);
List<StbActivity> list = new ArrayList<>();
@@ -41,3 +40,70 @@ then
modify ( $stbActivity ) { setStbActivity(list) }
end
rule "completeDataEffettiva"
no-loop
when
eval(completeRulesEnabled && customerDb == IntegryCustomerDB.Integry_Studioml)
$stbActivity : StbActivity(flagTipologia == "A" && parentActivityId != null && (operation == OperationType.INSERT || operation == OperationType.UPDATE || operation == OperationType.INSERT_OR_UPDATE))
then
String sql =
Query.format(
"SELECT CAST(IIF((stb_activity.effective_time IS NULL OR stb_activity.effective_time > %s), 1, 0) AS BIT) AS bool,\n" +
" stb_activity.effective_time\n" +
"FROM stb_activity\n" +
"WHERE stb_activity.activity_id = %s",
$stbActivity.getEffectiveTime(), $stbActivity.getParentActivityId()
);
HashMap<String,Object> resultQuery = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
boolean result = (boolean) resultQuery.get("bool");
Date effectiveTime = (Date) resultQuery.get("effective_time");
List<StbActivity> list = new ArrayList<>();
if (result) {
StbActivity parent = new StbActivity()
.setActivityId($stbActivity.getParentActivityId())
.setEffectiveTime(effectiveTime);
parent.setOperation(OperationType.UPDATE);
list.add(parent);
}
modify ( $stbActivity ) { setStbActivity(list) }
end
rule "completeResultId"
no-loop
when
eval(completeRulesEnabled && customerDb == IntegryCustomerDB.Integry_Studioml)
$stbActivity : StbActivity(flagTipologia == "A" && parentActivityId != null && (operation == OperationType.INSERT || operation == OperationType.UPDATE || operation == OperationType.INSERT_OR_UPDATE))
then
String sql =
Query.format(
"WITH childActivityResult AS (SELECT *\n" +
" FROM stb_activity_result\n" +
" WHERE activity_result_id = %s)\n" +
"SELECT CAST(IIF(\n" +
" (stb_activity_result.flag_stato_attivita IS NULL OR\n" +
" stb_activity_result.flag_stato_attivita <> '4' OR\n" +
" stb_activity_result.flag_stato_attivita <> '3' OR\n" +
" stb_activity_result.flag_stato_attivita <> '1'),\n" +
" 1, 0) AS BIT) AS 'execute',\n" +
" IIF(childActivityResult.flag_stato_attivita <> 0, 'DA COMPLETARE', childActivityResult.activity_result_id) AS 'stato'\n" +
"FROM stb_activity\n" +
" CROSS APPLY childActivityResult\n" +
" LEFT OUTER JOIN stb_activity_result ON stb_activity_result.activity_result_id = stb_activity.activity_result_id\n" +
"WHERE stb_activity.activity_id = %s",
$stbActivity.getActivityResultId(), $stbActivity.getParentActivityId()
);
HashMap<String,Object> resultQuery = UtilityDB.executeSimpleQueryOnlyFirstRow(conn, sql);
boolean execute = (boolean) resultQuery.get("execute");
String stato = (String) resultQuery.get("stato");
List<StbActivity> list = new ArrayList<>();
if (execute) {
StbActivity parent = new StbActivity()
.setActivityId($stbActivity.getParentActivityId())
.setActivityResultId(stato);
parent.setOperation(OperationType.UPDATE);
list.add(parent);
}
modify ( $stbActivity ) { setStbActivity(list) }
end

View File

@@ -214,13 +214,12 @@ public class ActivityController {
}
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_COMMESSA, method = RequestMethod.GET)
public ServiceRestResponse getCommessa(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String config) throws Exception {
return ServiceRestResponse.createPositiveResponse(activityService.getCommessa());
@RequestMapping(value = EmsRestConstants.PATH_ACTIVITY_COMMESSE, method = RequestMethod.GET)
public ServiceRestResponse getCommesse(HttpServletRequest request,
@RequestParam(CommonConstants.PROFILE_DB) String config,
@RequestParam(required = false) String username) throws Exception {
return ServiceRestResponse.createPositiveResponse(activityService.getCommesse(username));
}
@PreAuthorize("isAuthenticated()")

View File

@@ -1,5 +1,8 @@
package it.integry.ems.activity.dto;
import java.util.Arrays;
import java.util.List;
public class SearchActivityDTO {
private String activityId;
@@ -32,4 +35,8 @@ public class SearchActivityDTO {
this.activityDescription = activityDescription;
return this;
}
public List<String> getKeywords() {
return Arrays.asList(activityDescription.split("[^a-zA-Z0-9]+"));
}
}

View File

@@ -740,7 +740,7 @@ public class ActivityService {
.setActivityId(activityId);
stbActivityP.setOperation(OperationType.UPDATE);
entityList.add(stbActivityP);
} else if (!existSubAct && !existCloseActivity ) {
} else if (!existSubAct && !existCloseActivity) {
newStbActivity(codJcom, activityId, parentActivityId, stbActivityP);
stbActivityP.setOperation(OperationType.UPDATE);
entityList.add(stbActivityP);
@@ -957,9 +957,9 @@ public class ActivityService {
" INNER JOIN (SELECT *\n" +
" FROM jtb_comt\n";
if (year == null && activityId == null ) {
if (year == null && activityId == null) {
sql += " WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA')) jtb_comt\n";
} else if (activityId == null ) {
} else if (activityId == null) {
sql += " WHERE stato_commessa = 'CHIUSA'\n" +
" AND (YEAR(data_inizi_lav) = " + year + " OR YEAR(data_cons) = " + year + ")) jtb_comt\n";
}
@@ -1239,11 +1239,16 @@ public class ActivityService {
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityProductsDTO.class);
}
public List<ActivityCommessaDTO> getCommessa() throws Exception {
public List<ActivityCommessaDTO> getCommesse(String username) throws Exception {
String sql = "SELECT cod_jcom, descrizione \n" +
"FROM jtb_comt \n" +
"WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA') \n" +
"ORDER BY cod_jcom ASC";
"WHERE stato_commessa IN ('IN CORSO', 'POST VENDITA', 'TRATTATIVA') \n";
if(username != null && !username.isEmpty()){
sql += Query.format("AND cod_jflav_tec = %s \n", username);
}
sql += "ORDER BY cod_jcom ASC";
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, ActivityCommessaDTO.class);
}
@@ -1596,8 +1601,7 @@ public class ActivityService {
" AND EXISTS (SELECT * FROM vtb_clie WHERE vtb_clie.cod_anag = gtb_anag.cod_anag AND vtb_clie.flag_stato = 'A'))\n" +
"SELECT *\n" +
"FROM commesse\n" +
"WHERE conta = 1\n" +
" AND last_update < DATEADD(MONTH, -1, GETDATE())";
"WHERE conta = 1\n";
return UtilityDB.executeSimpleQueryDTO(multiDBTransactionManager.getPrimaryConnection(), sql, OldUpdateDTO.class);
}
@@ -1613,23 +1617,29 @@ public class ActivityService {
public List<ActivityDTO> searchActivity(SearchActivityDTO searchActivityDTO) throws Exception {
List<String> whereCondList = new ArrayList<>();
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getActivityDescription())){
whereCondList.add(
"stb_activity.activity_description LIKE " +
UtilityDB.valueToString("%" + searchActivityDTO.getActivityDescription().replaceAll("[*]", "%") + "%") +
" \n"
);
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getActivityDescription())) {
StringBuilder whereCond = new StringBuilder("stb_activity.activity_description ");
List<String> keywords = searchActivityDTO.getKeywords();
whereCond.append("LIKE ").append(UtilityDB.valueToString("%" + keywords.get(0) + "%"));
for (int i = 1; i < keywords.size(); i++) {
whereCond.append(" AND stb_activity.activity_description LIKE ")
.append(UtilityDB.valueToString("%" + keywords.get(i) + "%"));
}
whereCondList.add(whereCond.append("\n").toString());
}
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getActivityId())){
whereCondList.add("stb_activity.activity_id LIKE "+
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getActivityId())) {
whereCondList.add("stb_activity.activity_id LIKE " +
UtilityDB.valueToString("%" + searchActivityDTO.getActivityId().replaceAll("[*]", "%") + "%") +
" \n"
);
}
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getCodJcom())){
whereCondList.add("stb_activity.cod_jcom LIKE "+
if (!UtilityString.isNullOrEmpty(searchActivityDTO.getCodJcom())) {
whereCondList.add("stb_activity.cod_jcom LIKE " +
UtilityDB.valueToString("%" + searchActivityDTO.getCodJcom().replaceAll("[*]", "%") + "%") +
" \n"
);
@@ -1771,10 +1781,10 @@ public class ActivityService {
" HAVING COUNT(DISTINCT flag_tipologia_next) = 1)\n" +
" AND flag_tipologia_next = 'A')\n");
if (whereCondList.size() == 1){
if (whereCondList.size() == 1) {
sql.append(" AND ").append(whereCondList.get(0));
} else {
for (String whereCond : whereCondList){
for (String whereCond : whereCondList) {
sql.append(" AND ").append(whereCond);
}
}

View File

@@ -408,7 +408,7 @@ public class SystemService {
public List<UserDTO> getUsers(String userName) throws Exception {
String sql = "SELECT DISTINCT jrl_flav_users.user_name, stb_user.full_name, stb_user.e_mail\n" +
String sql = "SELECT DISTINCT jrl_flav_users.user_name, stb_user.full_name, stb_user.e_mail, stb_user.key_group\n" +
"FROM jrl_flav_users\n" +
" INNER JOIN stb_user ON stb_user.user_name = jrl_flav_users.user_name\n" +
"WHERE stb_user.flag_attivo = 'S'\n" +