Update SureopsService.java

This commit is contained in:
string 2025-04-26 10:31:26 +05:30
parent c809b4f183
commit ccb2156b34

View File

@ -4,10 +4,16 @@ import java.io.BufferedWriter;
import java.io.File; import java.io.File;
import java.io.FileWriter; import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;
import com.realnet.utils.PortConstant;
@Service @Service
public class SureopsService { public class SureopsService {
@ -15,14 +21,27 @@ public class SureopsService {
@Value("${projectPath}") @Value("${projectPath}")
private String projectPath; private String projectPath;
@Autowired
private Script_Making script_serviceMaking;
public void createHtmlFiles(Integer projId, Map<String, String> pageHtmlMap) throws IOException { public void createHtmlFiles(Integer projId, Map<String, String> pageHtmlMap) throws IOException {
String prj_url = PortConstant.BACKEND_PORTAL_DOMAIN + "/token/fnd1/callingsureops/getproject/" + projId;
// get project
ResponseEntity<Object> prj = GET(prj_url);
Object prj_body = prj.getBody();
List<String> list = script_serviceMaking.callforproject(prj_body);
String PRJ_NAME = list.get(0);
int i = 0; int i = 0;
for (Map.Entry<String, String> entry : pageHtmlMap.entrySet()) { for (Map.Entry<String, String> entry : pageHtmlMap.entrySet()) {
String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name String pageName = entry.getKey().trim().replaceAll("\\s+", "_"); // remove spaces from name
String htmlContent = entry.getValue(); String htmlContent = entry.getValue();
String folderPath = projectPath + File.separator + projId + File.separator + "index"; String folderPath = projectPath + File.separator + projId + File.separator + "index" + File.separator
+ PRJ_NAME;
File file = new File(folderPath + "/" + pageName + ".html"); File file = new File(folderPath + "/" + pageName + ".html");
// Ensure directory exists // Ensure directory exists
@ -47,4 +66,13 @@ public class SureopsService {
} }
} }
public ResponseEntity<Object> GET(String get) {
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<Object> u = restTemplate.getForEntity(get, Object.class);
return u;
}
} }