31-01-2925 12:43

feature_dev_harish
Harish Kumar 2025-01-31 12:43:46 +05:30
parent 7225c43e89
commit 6cff7a2c5b
5 changed files with 132 additions and 3 deletions

View File

@ -1,6 +1,7 @@
package com.sahyog.app.inbound.masterdata.controller;
import java.util.List;
import java.util.Map;
import javax.validation.Valid;
@ -29,6 +30,7 @@ import com.sahyog.app.inbound.masterdata.service.MaterialMasterService;
import com.sahyog.app.inbound.masterdata.service.TransporterMasterService;
import com.shayog.app.inbound.common.dto.ResponseDTO;
import com.sahyog.app.inbound.masterdata.service.TZoneMasterService;
import com.sahyog.app.inbound.masterdata.service.TaxregimeMasterService;
import org.springframework.http.MediaType;
@ -43,6 +45,9 @@ public class MasterController {
@Autowired
private CodeMasterService userService;
@Autowired
TaxregimeMasterService taxregimeService;
@Autowired
private PlantMasterService plantService;
@ -163,6 +168,55 @@ public class MasterController {
}
}
@GetMapping(value = "/getDropdown")
public ResponseEntity<Map<String, Object>> getDropdownvalues() {
try {
Map<String, Object> res = plantService.getDropDownValues();
return ResponseEntity.status(HttpStatus.CREATED).body(res);
} catch (Exception e) {
log.error("Unexpected error occurred in TZone addition: {}", e.getMessage(), e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}
@GetMapping(value = "/getTaxregime")
public ResponseEntity<Map<String, Object>> getTaxregimeMaster(@RequestParam("taxregimeCode") String taxregimeCode,
@RequestParam("taxregimeTypecode") String taxregimeTypecode) {
try {
log.info("Received request to get tax by code: {} and code type : {}", taxregimeCode, taxregimeTypecode);
Map<String, Object> res = taxregimeService.getTaxregimeMaster(taxregimeCode, taxregimeTypecode);
return ResponseEntity.status(HttpStatus.CREATED).body(res);
} catch (Exception e) {
log.error("Unexpected error occurred in Taxregime fetch : {}", e.getMessage(), e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}
@GetMapping(value = "/getTransAndPlant")
public ResponseEntity<Map<String, Object>> getTransAndPlant(@RequestParam("transCode") String transCode,
@RequestParam("plantCode") String plantCode) {
try {
log.info("Received request to get tax by code: {} and code type : {}", transCode, plantCode);
Map<String, Object> res = plantService.getTransAndPlantDetails(transCode, plantCode);
return ResponseEntity.status(HttpStatus.CREATED).body(res);
} catch (Exception e) {
log.error("Unexpected error occurred in transAndPlant fetch : {}", e.getMessage(), e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(null);
}
}
// getByMaterialCode(String materialCode, String plantCode)
// @PostMapping(value = "updateUser", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
// public ResponseEntity<String> createUpdateUser(@Valid @RequestBody UserDTO userDTO) {

View File

@ -6,6 +6,7 @@ package com.sahyog.app.inbound.masterdata.service;
import com.sahyog.app.inbound.masterdata.dto.PlantMasterDTO;
import java.util.List;
import java.util.Map;
//import com.shayog.app.inbound.common.dto;
@ -17,5 +18,9 @@ public interface PlantMasterService {
* Retrieves Code based on Key passed.
*/
PlantMasterDTO getByPlantCode(String plantCode);
Map<String, Object> getDropDownValues();
Map<String, Object> getTransAndPlantDetails(String transCode, String plantCode);
}

View File

@ -0,0 +1,8 @@
package com.sahyog.app.inbound.masterdata.service;
import java.util.Map;
public interface TaxregimeMasterService {
public Map<String, Object> getTaxregimeMaster(String taxregimeCode, String taxregimeTypecode);
}

View File

@ -1,7 +1,9 @@
package com.sahyog.app.inbound.masterdata.serviceImpl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.slf4j.Logger;
@ -10,6 +12,7 @@ import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import com.sahyog.app.inbound.masterdata.dto.PlantMasterDTO;
@ -24,11 +27,14 @@ public class PlantMasterServiceImpl implements PlantMasterService {
@Autowired
private PlantMasterRepository PlantMasterRepo;
@Autowired
private JdbcTemplate temp;
private static final Logger log = LoggerFactory.getLogger(PlantMasterServiceImpl.class);
@Override
public PlantMasterDTO getByPlantCode(String plantCode) {
// TODO Auto-generated method stub
// TODO Auto-generated method stub
PlantMasterDTO pmDTO = new PlantMasterDTO();
try {
// fetch CodeMaster object
@ -37,9 +43,36 @@ public class PlantMasterServiceImpl implements PlantMasterService {
BeanUtils.copyProperties(pmEntity, pmDTO);
}
} catch (Exception e) {
log.error("Unexpected error occurred: {}", e.getMessage(), e);
log.error("Unexpected error occurred: {}", e.getMessage(), e);
}
return pmDTO;
}
@Override
public Map<String, Object> getDropDownValues() {
List<String> materialCode = temp.queryForList("SELECT DISTINCT `material_code` FROM `materialmaster`",
String.class);
List<String> plantCode = temp.queryForList("SELECT DISTINCT `plant_code` FROM `plantmaster`", String.class);
List<String> fromLocation = temp.queryForList("SELECT DISTINCT `from_location` FROM `tzonemaster`",
String.class);
Map<String, Object> res = new HashMap<>();
res.put("Plant", plantCode);
res.put("prodect", materialCode);
res.put("fromLocation", fromLocation);
return res;
}
@Override
public Map<String, Object> getTransAndPlantDetails(String transCode, String plantCode) {
Map<String, Object> transporterDetails = temp.queryForMap(
"SELECT `transporter_code`,`state_id`,`tax_regime`,`tax_rate` FROM `transportermaster` WHERE `transporter_code`='"
+ transCode + "'");
String plantStateId = temp.queryForObject(
"SELECT `state_id` FROM `plantmaster` WHERE `plant_code`='" + plantCode + "'", String.class);
Map<String, Object> res = new HashMap<>();
res.put("transCode", transporterDetails);
res.put("plant", plantStateId);
return res;
}
}

View File

@ -0,0 +1,29 @@
package com.sahyog.app.inbound.masterdata.serviceImpl;
import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import com.sahyog.app.inbound.masterdata.service.TaxregimeMasterService;
@Service
public class TaxregimeMasterServiceimpl implements TaxregimeMasterService {
@Autowired
JdbcTemplate temp;
private static final Logger log = LoggerFactory.getLogger(TaxregimeMasterServiceimpl.class);
@Override
public Map<String, Object> getTaxregimeMaster(String taxregimeCode, String taxregimeTypecode) {
String query = "SELECT `taxregime_id`,`taxregime_code`,`taxregime_typecode`,`tax_rate`,`igst_rate`,`sgst_rate`,`cgst_rate`,`status` FROM `taxregimemaster` WHERE `taxregime_code`='"
+ taxregimeCode + "' AND `taxregime_typecode`=" + taxregimeTypecode + "'";
log.info("query => {} ", query);
Map<String, Object> taxregimemaster = temp.queryForMap(query);
return taxregimemaster;
}
}