add line wise detail day target total machine

pull/24/head
usama.jameel 2025-05-22 09:25:13 +05:00
parent 3c129e4e66
commit 29ccd209f6
14 changed files with 138 additions and 30 deletions

View File

@ -0,0 +1,14 @@
package com.utopiaindustries.auth;
import org.springframework.security.access.prepost.PreAuthorize;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@PreAuthorize("hasAnyRole('ROLE_INVENTORY_ACCOUNT','ROLE_ADMIN')")
public @interface InventoryAccountRole {
}

View File

@ -1,16 +1,15 @@
package com.utopiaindustries.controller;
import com.utopiaindustries.auth.AdminRole;
import com.utopiaindustries.auth.InventoryAccountRole;
import com.utopiaindustries.model.ctp.InventoryAccount;
import com.utopiaindustries.service.InventoryAccountService;
import com.utopiaindustries.util.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
@Controller
@AdminRole
@InventoryAccountRole
@RequestMapping( "/inventory-accounts" )
public class InventoryAccountController {

View File

@ -196,7 +196,7 @@ public class FinishedItemDAO {
return namedParameterJdbcTemplate.query(SELECT_BY_JOB_CARD_AND_DATE, params, new FinishedItemRowMapper());
}
public Long findByOperationDoneDate(String startDate, String endDate, String qaStatus, List<Long> ids){
public Long findByOperationDoneDateAndIdsAndQaStatus(String startDate, String endDate, String qaStatus, List<Long> ids){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue( "start_date", startDate );
params.addValue( "end_date", endDate );

View File

@ -20,7 +20,25 @@ public class InventoryAccountDAO {
private final String SELECT_QUERY = String.format( "SELECT * FROM %s WHERE id = :id", TABLE_NAME );
private final String SELECT_ALL_QUERY = String.format( "SELECT * FROM %s ORDER BY title DESC", TABLE_NAME );
private final String DELETE_QUERY = String.format( "DELETE FROM %s WHERE id = :id", TABLE_NAME );
private final String INSERT_QUERY = String.format( "INSERT INTO %s (id, title, parent_entity_type, parent_entity_id, active, created_by, created_at, location_site_id, notes, is_packaging) VALUES (:id, :title, :parent_entity_type, :parent_entity_id, :active, :created_by, :created_at, :location_site_id, :notes, :is_packaging) ON DUPLICATE KEY UPDATE title = VALUES(title), parent_entity_type = VALUES(parent_entity_type), parent_entity_id = VALUES(parent_entity_id), active = VALUES(active), created_by = VALUES(created_by), created_at = VALUES(created_at), location_site_id = VALUES(location_site_id), notes = VALUES(notes), is_packaging = VALUES(is_packaging)", TABLE_NAME );
private final String INSERT_QUERY = String.format(
"INSERT INTO %s (id, title, parent_entity_type, parent_entity_id, active, created_by, created_at, location_site_id, notes, is_packaging, article_name, daily_target, total_machines, hourly_target) " +
"VALUES (:id, :title, :parent_entity_type, :parent_entity_id, :active, :created_by, :created_at, :location_site_id, :notes, :is_packaging, :article_name, :daily_target, :total_machines, :hourly_target) " +
"ON DUPLICATE KEY UPDATE " +
"title = VALUES(title), " +
"parent_entity_type = VALUES(parent_entity_type), " +
"parent_entity_id = VALUES(parent_entity_id), " +
"active = VALUES(active), " +
"created_by = VALUES(created_by), " +
"created_at = VALUES(created_at), " +
"location_site_id = VALUES(location_site_id), " +
"notes = VALUES(notes), " +
"is_packaging = VALUES(is_packaging), " +
"article_name = VALUES(article_name), " +
"daily_target = VALUES(daily_target), " +
"hourly_target = VALUES(hourly_target), " +
"total_machines = VALUES(total_machines)",
TABLE_NAME
);
private final String SELECT_BY_IDS = String.format( "SELECT * FROM %s WHERE id IN (:ids)", TABLE_NAME );
private final String SELECT_BY_IDS_AND_PARENT_ID = String.format( "SELECT * FROM %s WHERE active = TRUE AND id IN (:ids) AND parent_entity_id = :parent_entity_id", TABLE_NAME );
private final String SELECT_BY_IDS_AND_PARENT_IDS = String.format( "SELECT * FROM %s WHERE active = TRUE AND id IN (:ids) AND parent_entity_id IN (:parent_entity_ids)", TABLE_NAME );
@ -45,6 +63,10 @@ public class InventoryAccountDAO {
.addValue( "created_at", inventoryAccount.getCreatedAt() )
.addValue( "location_site_id", inventoryAccount.getLocationSiteId() )
.addValue( "notes", inventoryAccount.getNotes() )
.addValue( "article_name", inventoryAccount.getArticleName() )
.addValue( "total_machines", inventoryAccount.getTotalMachines() )
.addValue( "daily_target", inventoryAccount.getDailyTarget() )
.addValue( "hourly_target", inventoryAccount.getHourlyTarget() )
.addValue("is_packaging", inventoryAccount.getIsPackaging() );
return params;
}

View File

@ -20,6 +20,10 @@ public class InventoryAccountRowMapper implements RowMapper<InventoryAccount> {
}
inventoryAccount.setLocationSiteId( rs.getInt( "location_site_id" ) );
inventoryAccount.setNotes( rs.getString( "notes" ) );
inventoryAccount.setArticleName( rs.getString( "article_name" ) );
inventoryAccount.setDailyTarget( rs.getLong( "daily_target" ) );
inventoryAccount.setTotalMachines( rs.getLong( "total_machines" ) );
inventoryAccount.setHourlyTarget( rs.getLong( "hourly_target" ) );
inventoryAccount.setIsPackaging( rs.getBoolean("is_packaging" ) );
return inventoryAccount;
}

View File

@ -221,7 +221,7 @@ public class InventoryTransactionLegDAO {
return namedParameterJdbcTemplate.query( SELECT_JOB_CARD_And_Date_Type_Account_Id , params, new InventoryTransactionLegRowMapper() );
}
public List<Long> getParentIDsOFRemainingINVENTORY(String parentType, Integer accountId){
public List<Long> findRemainingByParentTypeAndAccountID(String parentType, Integer accountId){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue("account_id", accountId );
params.addValue("parent_document_type", parentType );

View File

@ -98,7 +98,7 @@ public class PackagingItemsDAO {
return namedParameterJdbcTemplate.query(SELECT_BY_JOB_CARD_ID, params, new PackagingItemsRowMapper());
}
public Long findByDateANDIDs(String startDate, String endDate,List<Long> ids){
public Long findByDateAndIds(String startDate, String endDate,List<Long> ids){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue( "start_date", startDate );
params.addValue( "end_date", endDate );

View File

@ -174,7 +174,7 @@ public class StitchingOfflineItemDAO {
return namedParameterJdbcTemplate.query( SELECT_BY_JOB_CARD_AND_DATE , params, new StitchingOfflineItemRowMapper() );
}
public Long findByQCDoneDate(String startDate, String endDate, String qaStatus, List<Long> ids){
public Long findByQCOperationDateAndIds(String startDate, String endDate, String qaStatus, List<Long> ids){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue( "start_date", startDate );
params.addValue( "end_date", endDate );
@ -183,7 +183,7 @@ public class StitchingOfflineItemDAO {
Long count = namedParameterJdbcTemplate.queryForObject(SELECT_BY_DATE_QA_STATUS, params, Long.class);
return count != null ? count : 0;
}
public Long findByQCDoneDateApproved(String startDate, String endDate, String qaStatus){
public Long findByQCOperationDateAndApproved(String startDate, String endDate, String qaStatus){
MapSqlParameterSource params = new MapSqlParameterSource();
params.addValue( "start_date", startDate );
params.addValue( "end_date", endDate );

View File

@ -10,5 +10,6 @@ public enum Roles {
ROLE_FINISHING,
ROLE_PACKAGING,
ROLE_REPORTING,
ROLE_PURCHASE_ORDER
ROLE_PURCHASE_ORDER,
ROLE_INVENTORY_ACCOUNT
}

View File

@ -14,6 +14,11 @@ public class InventoryAccount {
private Integer locationSiteId;
private String notes;
private Boolean isPackaging;
private String articleName;
private long dailyTarget;
private long totalMachines;
private long hourlyTarget;
//wrapper
private String locationTitle;
@ -105,6 +110,37 @@ public class InventoryAccount {
this.locationTitle = locationTitle;
}
public String getArticleName() {
return articleName;
}
public void setArticleName(String articleName) {
this.articleName = articleName;
}
public long getDailyTarget() {
return dailyTarget;
}
public void setDailyTarget(long dailyTarget) {
this.dailyTarget = dailyTarget;
}
public long getTotalMachines() {
return totalMachines;
}
public void setTotalMachines(long totalMachines) {
this.totalMachines = totalMachines;
}
public long getHourlyTarget() {
return hourlyTarget;
}
public void setHourlyTarget(long hourlyTarget) {
this.hourlyTarget = hourlyTarget;
}
@Override
public String toString() {
@ -119,6 +155,10 @@ public class InventoryAccount {
", locationSiteId=" + locationSiteId +
", notes='" + notes + '\'' +
", isPackaging=" + isPackaging +
", articleName='" + articleName + '\'' +
", dailyTarget=" + dailyTarget +
", totalMachines=" + totalMachines +
", hourlyTarget=" + hourlyTarget +
", locationTitle='" + locationTitle + '\'' +
'}';
}

View File

@ -47,6 +47,9 @@ public class DashboardService {
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.findAll();
InventoryAccount inventoryAccount = inventoryAccounts.stream()
.filter(e -> cuttingAccount.equals(e.getTitle())).findFirst().orElse(new InventoryAccount());
Map<String, Integer> inventoryAccountMap = inventoryAccounts.stream()
.filter(e -> cuttingAccount.equals(e.getTitle()) ||
stitchingAccount.equals(e.getTitle()) ||
@ -55,16 +58,17 @@ public class DashboardService {
.collect(Collectors.toMap(InventoryAccount::getTitle, e -> (int) e.getId()));
List<Long> stitchingItemIds = inventoryTransactionLegDAO.getParentIDsOFRemainingINVENTORY("STITCHING_OFFLINE", inventoryAccountMap.get(stitchingAccount));
List<Long> stitchingItemIds = inventoryTransactionLegDAO.findRemainingByParentTypeAndAccountID("STITCHING_OFFLINE", inventoryAccountMap.get(stitchingAccount));
List<Long> finishing = inventoryTransactionLegDAO.getInParentIdIdByDate("FINISHED_ITEM", inventoryAccountMap.get(finishingAccount));
List<Long> packagingItemIDs = inventoryTransactionLegDAO.getParentIDsOFRemainingINVENTORY("PACKAGING", inventoryAccountMap.get(packagingAccount));
List<Long> packagingItemIDs = inventoryTransactionLegDAO.findRemainingByParentTypeAndAccountID("PACKAGING", inventoryAccountMap.get(packagingAccount));
Long approvedStitchingOfflineItems = 0L;
Long qcReject = 0L;
if (stitchingItemIds != null && !stitchingItemIds.isEmpty()) {
approvedStitchingOfflineItems = stitchingOfflineItemDAO.findByQCDoneDateApproved(startDate1, endDate1, "APPROVED");
qcReject = stitchingOfflineItemDAO.findByQCDoneDate(null, endDate1, "REJECT", stitchingItemIds);
approvedStitchingOfflineItems = stitchingOfflineItemDAO.findByQCOperationDateAndApproved(startDate1, endDate1, "APPROVED");
qcReject = stitchingOfflineItemDAO.findByQCOperationDateAndIds(null, endDate1, "REJECT", stitchingItemIds);
}
Long alterationPieceFinish = 0L;
@ -74,19 +78,19 @@ public class DashboardService {
Long operationNotPerformed = 0L;
if (finishing != null && !finishing.isEmpty()) {
approved = finishedItemDAO.findByOperationDoneDate(startDate1, endDate1, "APPROVED", finishing);
operationNotPerformed = finishedItemDAO.findByOperationDoneDate(null, endDate1, "-", finishing);
rejectFinishedItem = finishedItemDAO.findByOperationDoneDate(null, endDate1, "REJECT", finishing);
washFinishedItem = finishedItemDAO.findByOperationDoneDate(startDate1, endDate1, "WASHED", finishing);
alterationPieceFinish = finishedItemDAO.findByOperationDoneDate(null, endDate1, "ALTER", finishing);
approved = finishedItemDAO.findByOperationDoneDateAndIdsAndQaStatus(startDate1, endDate1, "APPROVED", finishing);
operationNotPerformed = finishedItemDAO.findByOperationDoneDateAndIdsAndQaStatus(null, endDate1, "-", finishing);
rejectFinishedItem = finishedItemDAO.findByOperationDoneDateAndIdsAndQaStatus(null, endDate1, "REJECT", finishing);
washFinishedItem = finishedItemDAO.findByOperationDoneDateAndIdsAndQaStatus(startDate1, endDate1, "WASHED", finishing);
alterationPieceFinish = finishedItemDAO.findByOperationDoneDateAndIdsAndQaStatus(null, endDate1, "ALTER", finishing);
}
Long packagingItems = 0L;
Long packagingItemsHourly = 0L;
if (packagingItemIDs != null && !packagingItemIDs.isEmpty()) {
packagingItems = packagingItemsDAO.findByDateANDIDs(startDate1, endDate1, packagingItemIDs);
packagingItemsHourly = packagingItemsDAO.findByDateANDIDs(startDateWithHour, endDateWithHour, packagingItemIDs);
packagingItems = packagingItemsDAO.findByDateAndIds(startDate1, endDate1, packagingItemIDs);
packagingItemsHourly = packagingItemsDAO.findByDateAndIds(startDateWithHour, endDateWithHour, packagingItemIDs);
}
progress.put("Stitching", (float) approvedStitchingOfflineItems + qcReject);
@ -100,8 +104,8 @@ public class DashboardService {
progress.put("packaging", (float) packagingItems);
progress.put("Shift Achieved", (float) packagingItems);
progress.put("Efficiency", (float) packagingItems / 1000 * 100);
progress.put("Hourly Achieved", Float.valueOf(packagingItemsHourly));
progress.put("Efficiency", (float) packagingItems / inventoryAccount.getDailyTarget() * 100);
return progress;
@ -110,17 +114,16 @@ public class DashboardService {
public Map<String, String> getLineDetails(String lineNo) {
String cuttingAccount = "CUTTING ACCOUNT " + lineNo;
List<InventoryAccount> inventoryAccounts = inventoryAccountDAO.findAll();
String articleNote = inventoryAccounts.stream()
.filter(e -> cuttingAccount.equals(e.getTitle()))
.map(InventoryAccount::getNotes).findFirst().orElse(null);
InventoryAccount inventoryAccount = inventoryAccounts.stream()
.filter(e -> cuttingAccount.equals(e.getTitle())).findFirst().orElse(new InventoryAccount());
HashMap<String, String> details = new HashMap<>();
List<JobCard> jobCards = jobCardDAO.findAll();
details.put("Shift Target", 1000 + " Pcs");
details.put("articleNote", articleNote);
details.put("Hourly Target", 1000 / 24 + " Pcs");
details.put("Shift Target", inventoryAccount.getDailyTarget() + " Pcs");
details.put("articleName", inventoryAccount.getArticleName());
details.put("Hourly Target", inventoryAccount.getHourlyTarget() + " Pcs");
details.put("Total Induction", String.valueOf(jobCards.size()));
details.put("Total Machine", String.valueOf(30));
details.put("Total Machine", String.valueOf(inventoryAccount.getTotalMachines()));
details.put("Total Worker", String.valueOf(30));
details.put("line", "Line " + lineNo);
return details;

View File

@ -94,6 +94,15 @@
class="dropdown-item">User And Roles</a>
</div>
</li>
<li class="nav-item dropdown" sec:authorize="hasRole('ROLE_INVENTORY_ACCOUNT')">
<a class="nav-link dropdown-toggle" data-toggle="dropdown" href="#">Inventory Accounts</a>
<div class="dropdown-menu">
<!-- Add Inventory Accounts-->
<a th:href="@{/inventory-accounts}"
th:classappend="${#strings.startsWith(#httpServletRequest.getRequestURI(), '/ctp/inventory-accounts') ? 'active' : ''}"
class="dropdown-item">Inventory Accounts</a>
</div>
</li>
</ul>
<div class="dropdown page-header__user-menu">
<a href="#" class="dropdown-toggle btn btn-sm btn-outline-light" data-toggle="dropdown">

View File

@ -19,6 +19,22 @@
<label>Title</label>
<input class="form-control" th:field="*{title}" required>
</div>
<div class="col-sm-3 form-group">
<label>Article Name</label>
<input class="form-control" th:field="*{articleName}" >
</div>
<div class="col-sm-3 form-group">
<label>Day Target</label>
<input type="number" class="form-control" th:field="*{dailyTarget}" >
</div>
<div class="col-sm-3 form-group">
<label>Hourly Target</label>
<input type="number" class="form-control" th:field="*{hourlyTarget}" >
</div>
<div class="col-sm-3 form-group">
<label>Total Machine</label>
<input type="number" class="form-control" th:field="*{totalMachines}" >
</div>
<div class="col-sm-6 form-group">
<label>Notes</label>
<input class="form-control" th:field="*{notes}" required>

View File

@ -28,7 +28,7 @@
<div class="text-end">
<h3 class="fw-bold m-0 text-end "
th:text=" 'Total Machines: '+ ${detail.get('Total Machine')} ">0</h3>
<h3 class="fw-bold m-0 text-end" th:text="'Article: ' + ${detail.get('articleNote')}">
<h3 class="fw-bold m-0 text-end" th:text="'Article: ' + ${detail.get('articleName')}">
0</h3>
</div>
</div>