File size: 1,743 Bytes
68f7925
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

// ファイルパス
const cnPath = path.join(__dirname, '../public/dummy/get_proposal_cn.json');
const fvPath = path.join(__dirname, '../public/dummy/get_proposal_fv.json');

// データを読み込み
const cnData = JSON.parse(fs.readFileSync(cnPath, 'utf8'));
const fvData = JSON.parse(fs.readFileSync(fvPath, 'utf8'));

// FVデータから戦略とニーズのマッピングを取得
const strategyMapping = [];
Object.entries(fvData).forEach(([strategy, needs]) => {
  Object.keys(needs).forEach((need) => {
    strategyMapping.push({ strategy, need });
  });
});

// 新しい構造のデータを作成
const newCnData = {};

// 各戦略を初期化
Object.keys(fvData).forEach((strategy) => {
  newCnData[strategy] = {};
});

// A案、B案、C案... を戦略・ニーズに割り当て
const proposalKeys = ['A案', 'B案', 'C案', 'D案', 'E案', 'F案', 'G案', 'H案', 'I案'];

proposalKeys.forEach((proposalKey, index) => {
  if (index < strategyMapping.length && cnData[proposalKey]) {
    const { strategy, need } = strategyMapping[index];
    
    // cnフィールドでラップ
    newCnData[strategy][need] = {
      cn: cnData[proposalKey]
    };
  }
});

// 結果を保存
const outputPath = path.join(__dirname, '../public/dummy/get_proposal_cn.json');
fs.writeFileSync(outputPath, JSON.stringify(newCnData, null, 2));

console.log('CN dummy data converted successfully!');
console.log('Strategy mapping:');
strategyMapping.forEach((item, index) => {
  console.log(`  ${proposalKeys[index]} -> ${item.strategy} / ${item.need}`);
});